The easiest way to create a deep copy of an existing object (as opposed
to just a pointer to the original object) is to leverage the fact that
by default parameters are passed by value in Visual Foxpro. So to make
an copy:

* -- CODE START
* -- Your original object.
loMyObject = CreateObject("MyObject")
loMyObject.Property1="hello"

* -- A new instance to hold the copy.
        loMyCopy = CreateObject("MyObject")
        loMycopy = DoCopy(loMyCopy)

* -- Make an copy.
Function DoCopy(loObjectIn as Object)
Return loObjectIn
* -- CODE END


So then:
? loMyObject.Property1    yields "hello"
? loMyCopy.Property1      yields "hello"
loMyCopy.Property1 = "bonjour"
? loMyObject.Property1    yields "hello"
? loMyCopy.Property1      yields "bonjour"





-- 
  Alan Bourke
  alanpbourke (at) fastmail (dot) fm


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to