Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing class array properties to methods
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00332569
Message ID:
00332615
Views:
13
>Hi gang,
>
>I have a custom class in which I've defined an array property. I now want to pass that array, BY REFERENCE, to a method in the same class which updates that array, similar to the following:
>
>THIS.MyMethod( @THIS.MyArray )
>

Why do you need to pass the member array to a method of the parent class? It's already visible to the method...

You might try passing the name of the array, or checking to see if the passed parameter is null, and if so, assume that the member array is to be used.

>Doesn't work -- neither does removing the @ sign (the parameter shows as .F. in the method).
>
>This method MUST accept the name of another, non-property array as a parameter -- I can't assume automatic usage of THIS.MyArray in all cases. And, if I simply don't pass a parameter when I do want to use THIS.MyArray, then I don't have the array by reference -- or does that matter?

If you change a member array in a method of the object, the changes persist beyond the method call, because the array persists beyond the method call.

An alternative - why not pass an object reference in all cases, and have a member array in the object reference passed? IOW:

this.MyMethod(this) && references the local member array

LOCAL oParm
oParm = CREATEOBJ('Separator')
oParm.AddProperty('memberarray[1]')
* Populate the member array
this.myMethod(oParm) && references the same named member array in oParm

Procedure MyMethod
LPARAMETER toCarrierOfArray
* you now reference the array at all times as toCarrierOfArray.MemberArray[...]
*yadda, yadda, yadda
* copy the results back to another arrray if needed

>
>Any ideas would be greatly appreciated.
>
>TIA,
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