Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #11356 > unrolled thread

How to copy a listview variable?

Started byD.J.W. van Kooten <vankooten@removethis.ic2.com>
First post2018-02-14 17:09 +0100
Last post2018-02-15 16:50 +0100
Articles 10 — 5 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  How to copy a listview variable? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-02-14 17:09 +0100
    Re: How to copy a listview variable? "Jamal" <noooospam@example.com> - 2018-02-14 21:57 -0500
      Re: How to copy a listview variable? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-02-15 10:31 +0100
    Re: How to copy a listview variable? Karl Wochele <kw@ecos-system.invalid> - 2018-02-15 07:47 +0100
      Re: How to copy a listview variable? Karl Wochele <kw@ecos-system.invalid> - 2018-02-15 07:49 +0100
      Re: How to copy a listview variable? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-02-15 10:34 +0100
        Re: How to copy a listview variable? Mathias <mathias.hakansson@consultec.se> - 2018-02-15 02:01 -0800
          Re: How to copy a listview variable? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-02-15 12:18 +0100
            Re: How to copy a listview variable? Franz Rachbauer <office@rachbauer.org> - 2018-02-15 14:52 +0100
              Re: How to copy a listview variable? D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-02-15 16:50 +0100

#11356 — How to copy a listview variable?

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2018-02-14 17:09 +0100
SubjectHow to copy a listview variable?
Message-ID<vum88dddhdoa8oahff3v6850mdlgib5q9g@4ax.com>
We show a listview in a window and use that LV variable to pass to a
method to export the contents to Excel.

Now 1 client wants to see a few of these columns omiitted in the Excel
export. It is not difficult ti remove the columns
(oLVl:DeleteColumn(2) etc) but thet should not be deleted in the
'master' listview showing in the screen.

Problem is that doing this:

oLVCopy:=oLVOriginal

and then delete the columns in oLVCopy also deletes these columns in
oLVOriginal, which is apparently copied by reference.

What would be the quickets way to copy the listview in such a way that
I can still pass it after deleting the required columns to my Excel
function without changing the original listview?

Dick

[toc] | [next] | [standalone]


#11357

From"Jamal" <noooospam@example.com>
Date2018-02-14 21:57 -0500
Message-ID<p62su4$k05$1@news.albasani.net>
In reply to#11356
May be (NOT TESTED!):

oLVCopy := CopyListView(oLVOriginal)

FUNCTION CopyListView(oListViewOld as ListView)   as ListView PASCAL // pass 
by value
local   oNewListView as ListView
            oNewListView = oListViewOld
    return oNewListView


Jamal

"D.J.W. van Kooten"  wrote in message 
news:vum88dddhdoa8oahff3v6850mdlgib5q9g@4ax.com...

We show a listview in a window and use that LV variable to pass to a
method to export the contents to Excel.

Now 1 client wants to see a few of these columns omiitted in the Excel
export. It is not difficult ti remove the columns
(oLVl:DeleteColumn(2) etc) but thet should not be deleted in the
'master' listview showing in the screen.

Problem is that doing this:

oLVCopy:=oLVOriginal

and then delete the columns in oLVCopy also deletes these columns in
oLVOriginal, which is apparently copied by reference.

What would be the quickets way to copy the listview in such a way that
I can still pass it after deleting the required columns to my Excel
function without changing the original listview?

Dick 

[toc] | [prev] | [next] | [standalone]


#11360

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2018-02-15 10:31 +0100
Message-ID<crka8dh53779u5ujoj3luq2b2erln0ange@4ax.com>
In reply to#11357
Replying on message of Wed, 14 Feb 2018 21:57:08 -0500 from Jamal:


 Hello Jamal

>May be (NOT TESTED!):
>
>oLVCopy := CopyListView(oLVOriginal)

Thanks for your attempt, but unfortunately that gives the same result.

Dick

[toc] | [prev] | [next] | [standalone]


#11358

FromKarl Wochele <kw@ecos-system.invalid>
Date2018-02-15 07:47 +0100
Message-ID<p63adr$ell$1@solani.org>
In reply to#11356
Hi Dick,

usually I would say you could use aclone() with VO-objects. But I don't 
think that this will work because in a listview you remove the columns 
in the underlying windows-object. No idea how you can handle this.

Karl

Am 14.02.2018 um 17:09 schrieb D.J.W. van Kooten:
> We show a listview in a window and use that LV variable to pass to a
> method to export the contents to Excel.
> 
> Now 1 client wants to see a few of these columns omiitted in the Excel
> export. It is not difficult ti remove the columns
> (oLVl:DeleteColumn(2) etc) but thet should not be deleted in the
> 'master' listview showing in the screen.
> 
> Problem is that doing this:
> 
> oLVCopy:=oLVOriginal
> 
> and then delete the columns in oLVCopy also deletes these columns in
> oLVOriginal, which is apparently copied by reference.
> 
> What would be the quickets way to copy the listview in such a way that
> I can still pass it after deleting the required columns to my Excel
> function without changing the original listview?
> 
> Dick
> 

[toc] | [prev] | [next] | [standalone]


#11359

FromKarl Wochele <kw@ecos-system.invalid>
Date2018-02-15 07:49 +0100
Message-ID<p63ah4$ell$2@solani.org>
In reply to#11358
of course I meant oclone(), not aclone()...

Am 15.02.2018 um 07:47 schrieb Karl Wochele:
> Hi Dick,
> 
> usually I would say you could use aclone() with VO-objects. But I don't 
> think that this will work because in a listview you remove the columns 
> in the underlying windows-object. No idea how you can handle this.
> 
> Karl
> 
> Am 14.02.2018 um 17:09 schrieb D.J.W. van Kooten:
>> We show a listview in a window and use that LV variable to pass to a
>> method to export the contents to Excel.
>>
>> Now 1 client wants to see a few of these columns omiitted in the Excel
>> export. It is not difficult ti remove the columns
>> (oLVl:DeleteColumn(2) etc) but thet should not be deleted in the
>> 'master' listview showing in the screen.
>>
>> Problem is that doing this:
>>
>> oLVCopy:=oLVOriginal
>>
>> and then delete the columns in oLVCopy also deletes these columns in
>> oLVOriginal, which is apparently copied by reference.
>>
>> What would be the quickets way to copy the listview in such a way that
>> I can still pass it after deleting the required columns to my Excel
>> function without changing the original listview?
>>
>> Dick
>>

[toc] | [prev] | [next] | [standalone]


#11361

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2018-02-15 10:34 +0100
Message-ID<uuka8d5q3g93hbbj1n9p8k6c8625ks6pgd@4ax.com>
In reply to#11358
Replying on message of Thu, 15 Feb 2018 07:47:16 +0100 from Karl
Wochele:


 Hello Karl,


>usually I would say you could use oclone() with VO-objects. 

I was unaware of oClone(it's not even in the help...)

But unfortuntely also oClone modifies the original listview.

Dick

[toc] | [prev] | [next] | [standalone]


#11362

FromMathias <mathias.hakansson@consultec.se>
Date2018-02-15 02:01 -0800
Message-ID<3d09e830-acbc-4783-8912-c6f449a3b405@googlegroups.com>
In reply to#11361
Hi Dick,

The problem is that the column objects are still the same if you copy the list view object. I Think the smartest option is to send an Array of column names to use for your export as a parameter. Null value could mean exporting all columns leaving current functionality unchanged.

/MathiasH

Den torsdag 15 februari 2018 kl. 10:34:45 UTC+1 skrev D.J.W. van Kooten:
> Replying on message of Thu, 15 Feb 2018 07:47:16 +0100 from Karl
> Wochele:
> 
> 
>  Hello Karl,
> 
> 
> >usually I would say you could use oclone() with VO-objects. 
> 
> I was unaware of oClone(it's not even in the help...)
> 
> But unfortuntely also oClone modifies the original listview.
> 
> Dick

[toc] | [prev] | [next] | [standalone]


#11363

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2018-02-15 12:18 +0100
Message-ID<50ra8dpa05bt1u0j94opdag78e5da8n6fi@4ax.com>
In reply to#11362
Replying on message of Thu, 15 Feb 2018 02:01:00 -0800 (PST) from
Mathias:


 Hello Mathias


>The problem is that the column objects are still the same if you copy the list view object. I Think the smartest option is to send an Array of column names to use for your export as a parameter. Null value could mean exporting all columns leaving current functionality unchanged.
>
I have multiple alternative options to send the results to Excel. I
just wondered why it's not possible to really clone a listview object
like you can with an array. If there's a "trick" for it, I'd be ready
in a minute - other solutions take quite a bit more time.

Dick

[toc] | [prev] | [next] | [standalone]


#11364

FromFranz Rachbauer <office@rachbauer.org>
Date2018-02-15 14:52 +0100
Message-ID<p643bc$jqc$1@gioia.aioe.org>
In reply to#11363
Why not copy it in a loop only with needed cols?

LOCAL x AS DWORD
LOCAL oItem AS ListViewItem
LOCAL oCol as ListViewColumn

// lvwData has column "Text" and others
// lvwCopy only has column "Text"
oCol := ListViewColumn{20,#TXT}
oCol:Caption := "Text"
SELF:oDClvwCopy:AddColumn(oCol)

FOR x := 1 TO SELF:oDClvwData:ItemCount
	oItem := SELF:oDClvwData:GetItemAttributes(x)
	SELF:oDClvwCopy:AddItem(oItem)
NEXT

Regards Franz

Am 15.02.2018 um 12:18 schrieb D.J.W. van Kooten:
> Replying on message of Thu, 15 Feb 2018 02:01:00 -0800 (PST) from
> Mathias:
> 
> 
>   Hello Mathias
> 
> 
>> The problem is that the column objects are still the same if you copy the list view object. I Think the smartest option is to send an Array of column names to use for your export as a parameter. Null value could mean exporting all columns leaving current functionality unchanged.
>>
> I have multiple alternative options to send the results to Excel. I
> just wondered why it's not possible to really clone a listview object
> like you can with an array. If there's a "trick" for it, I'd be ready
> in a minute - other solutions take quite a bit more time.
> 
> Dick
> 

[toc] | [prev] | [next] | [standalone]


#11365

FromD.J.W. van Kooten <vankooten@removethis.ic2.com>
Date2018-02-15 16:50 +0100
Message-ID<pqab8d14s8a0trkb30cc805pm3troebs9l@4ax.com>
In reply to#11364
Replying on message of Thu, 15 Feb 2018 14:52:42 +0100 from Franz
Rachbauer:


 Hello Franz,

>Why not copy it in a loop only with needed cols?

I realize from a reply from Chris in the X# forum:

I think the quickest solution is what Franz posted in clcvo, just
create an emtpy new one and copy the data you need only.

Although personally I would change the approach and not depend on a
GUI item (ListView) for storing and passnig the data, but use an
intermediate array instead.


and of course he's right in there. 

One of my employees who wrote this LV->Excel years ago told me today
she also wrote a function to remove columns from the multi-dimensional
array we create from this LV and always use to export to Excel.

This worked nearly the same, just a bit further up in the program, and
is more elegant.

Thanks everyone for your comments!

Dick

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web