TOPIC: deepcopying recordcontrol data
#1778
deepcopying recordcontrol data 8 Months, 1 Week ago
I have recordcontrol, data is entered by user. Then i make a copy of recordcontrol data as temp data. several times I make a copy. Now all copies have same data, which is the last data. Seems like all copies are shallow. How to make deep copies of recordcontrols data? thanks...
 
 
#1779
Re:deepcopying recordcontrol data 8 Months, 1 Week ago
Are you using .Copy ?

If you just do x = y it is just a reference to the same object

x = y.Copy() will do a shallow copy but that is ok unless you have nested objects
 
 
andrew
 
#1780
Re:deepcopying recordcontrol data 8 Months, 1 Week ago
I try .Copy() with no luck. But I solve problem now in other way:

1. I have copy of recordcontrol data: a = Record(a:1 b:2)
2. Encode record: b = Display(a)
3. Decode data: c = b.Eval()

Result:
a = [b: 2, a: 1]
b = "[b: 2, a: 1]"
c = [b: 2, a: 1]

Encoded copies can not become changed. Works great! actually I liked to do some pickle/marshall like in python but did not know if Suneido has serialisations.
 
 
#1789
Re:deepcopying recordcontrol data 8 Months, 1 Week ago
Pack and Unpack are probably better unless you need a readable string. They are what is used to store data in the database.
 
 
andrew