Hi,
I have a very simple question. How do you copy an object? And I'm not talking about creating another reference to an object, I'm talking about creating another copy of an object.
Please help...
Thanx in advance, Steve.
Printable View
Hi,
I have a very simple question. How do you copy an object? And I'm not talking about creating another reference to an object, I'm talking about creating another copy of an object.
Please help...
Thanx in advance, Steve.
memcopy API ??
create a new object reference but don't set it. then use memcopy from the other object.
Don't ask me for code as I've never had to do it before ;)
For some reason you can't, I think it's beacuse of the way the interface and data are combined very closely, I usually incluse a function inside all my class modules that creates a copy of it, but other than that there's not a lot you can do, You could try something with the copymemory API but I don't think it'll work.
I think memcpy should work... you just have to know the size of your object, as I remember you can get it using LenB(Var)...
LenB doesn't work for objects. Also the object variable is an interface to the object, the data is stored elsewhere, I'm prety sure you'll just create another reference.Try anyway.
I tend to agree with Sam the only way I've been able to make a copy of an object it create a function that copies each property value to the new object. It's a brute force method but it works.
If anyone has a neater solution I would be all for it.