Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ARGG! VFP send my objects by reference, no by value!!!!
Message
From
07/03/2000 18:31:23
 
 
To
07/03/2000 18:05:14
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00342323
Message ID:
00343012
Views:
26
>>An object passed by val........oNewObj = (code to duplicate oObjeRef as a new instance)
>
>Ed, would this then be the equivalent of the function of a copy constructor in C++?
>

Pretty much on the money.

>This got me thinking. would this be sufficient to implement this(is deep copy the right term?) in VFP?
>

I think Dragan published some code a while ago that did the necessary work.

The loop below would need to be aware of the kind of thing being assigned, because objects can contain objects. You also have the issue of things like private data sessions to make life -really- messy.

>
>
>oObj = CREATEOBJECT("someObj")
>* Do stuff with oObj
>oNewObj = oObj.copy()
>
>* someObj::copy
>n = AMEMBERS(la_props,this)
>o = CREATEOBJECT ("someObj")
>FOR x = 1 TO n
>  o.&la_props[x] = this.&la_props[x]
>ENDFOR
>RETURN o
>
>* someObj::Error
>LPARAMETERS nError, cMethod, nLine
>IF UPPER(cMethod) = "COPY"
>  IF nError = 1743  && Property "name" is read-only
>    RETURN .t.
>  ENDIF
>ENDIF
>* Normal error handling goes here
>
>
>Does that look right?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform