[Gambas-user] Trying to copy a collection with problems
Benoit Minisini
gambas at ...1...
Sun Mar 30 15:37:39 CEST 2008
On dimanche 30 mars 2008, richard terry wrote:
> I'm working on the past history in my program.
>
> I've a collection of these for aperson
>
> ie person.pasthistory = the collection. I can add to this, iterate through
> it etc, no problem.
>
> I want to copy this to keep a 'backup copy' to later check if any of the
> original data has been changed, and have tried this
>
> In my frmPastHistory I have this:
>
> Public PH_Copy As cPastHistory
>
> When the form loads I use the data from the calling form (frmClinical) and
> do this:
>
> public sub form_open()
>
> PH_Copy = New Collection
> H_Copy = frmClinical.currentPatient.past_history
>
>
> Now what happens is if I change anything in
> frmClinical.currentPatient.past_history collection after that - it
> automatically changes in the Backup collection, so it seems that I'm just
> pointing to a memory address somehow, not creating an independant
> collection.
>
> Any help appreciated. Hope this makes sense.
>
> Regards
>
> Richard.
>
Collection.Copy() does not exist: I am lazy, so I didn't write it, so you must
do it yourself:
DIM cSource AS Collection
DIM cDest AS NEW Collection
DIM vVal AS Variant
FOR EACH vVal IN cSource
cDest[cSource.Key] = vVal
NEXT
Regards,
--
Benoit Minisini
More information about the User
mailing list