Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copying an Object
Message
 
 
To
04/05/2005 13:58:29
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01010933
Message ID:
01010942
Views:
28
mvar2 = CopyObject(mvar1)
...
FUNCTION CopyObject
LPARAMETERS toObject
LOCAL  laProps[1], lnI, loNewObject, lnCount, lcPropName
loNewObject = CREATEOBJECT("Empty")
lnCount = AMEMBERS(laProps, toObject, 0)
FOR lnI=1 TO lnCount
	lcPropName = LOWER(laProps[lnI])
	IF TYPE([ALEN( toObject.&lcPropName)]) = "N"
		* Array
		ADDPROPERTY(loNewObject, lcPropName + "[1]", Null )
		= ACOPY(toObject.&lcPropName, loNewObject.&lcPropName)
	ELSE
		ADDPROPERTY(loNewObject, lcPropName, EVALUATE(" toObject." + lcPropName) )
	ENDIF	
ENDFOR

RETURN loNewObject
>I have an object that came from a scatter of a table:
>
>scatter name mvar memo
>
>When I copy mvar to mvar2 (mvar2=mvar), then make a change to mvar.cust_id, mvar2.cust_id also changes (as I guess they are both references to the same data). How can I change mvar without changing mvar2 (ie; just make a copy)?
>
>Thanks in advance...
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform