Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning an Array from a Function
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00338850
Message ID:
00340689
Views:
35
>When would you pass an object by reference, like
>uResult = Bar(@oFoo)
>and why?
>

If the method/function might need to actually destroy the referenced object directly, or might substitute a different object; it causes the original object reference to be altered within the called procedure. For example, oFoo could be an array of object refs (which I'd probably have named aoFoo, but that's a different issue) where I wanted the array of references to be altered by the called code. Or in an object factory, I might create a variable in the caller that had nothing in it to receive an object created by the called code, while still being able to return a result through the function code, eg:
oFoo = NULL
IF ObjectFactory.CreateMeAFoo(@oFoo,bar,mumble,bletch)
   *
   *  Do something useful with oFoo
   *
ELSE
   *
   *  oFoo can contain an error object, or might remain null, or receive some
   *  non-usable Foo thingy, so I do something else
   *
ENDIF
YMMV. You may not have a use for this. I do. You may never be involved with the issue of a copy of an object vs a copy of an object reference. I am.
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