Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning an Array from a Function
Message
From
29/02/2000 11:38:50
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00338850
Message ID:
00339169
Views:
25
>So you can add/modify properties of a passed by value object but you can't modify the object itself. But if you do pass it by reference (@) then you can actually change the object.
>

If you pass by value, the object is passed, but reassigning the object reference in the called function/method does not affect the original calling object reference. You can modify to your heart's content; if you reassign the pass-by-value object ref, the original object ref from the calling code remains intact.

If you pass by ref, and reassign the object ref in the called code, the modified reference is passed back, so the effects can be devastating. If for example:

oOriginal = CREATEOBJ('someclass')
=ResetParmToNull(oOriginal)
? ISNULL(oOriginal) && .F.
oOriginal=ResetParmToNull(oOriginal)
? ISNULL(oOriginal) && .T.
oOriginal = CREATEOBJ('someclass')
=ResetParmToNull(@oOriginal)
? ISNULL(oOriginal) && .T.

FUNCTION ResetParmToNull
LPARAMETER tuValue
tuValue=NULL
RETURN tuValue

DEFINE CLASS SomeClass AS Custom
ENDDEFINE


>Object variables have their own set of rules is what everyone is telling me. Since I only pass object variables by value and I know this behavior (if not explicitly then intuitively), I can live with it.
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
Reply
Map
View

Click here to load this message in the networking platform