Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pass variable by reference into a property
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00904349
Message ID:
00904355
Views:
14
Nick,

>Anyone know if there is a way to pass a value into a method by reference and assign that to an Object.Property. Something like:

See if this example helps explain:
pcMyVar=.F.
myObj = createobject( "myObj" )
? myObj.Process(@pcMyVar) && returned value
? pcMyVar && altered value
? myObj.cMyVar && .f.

pcMyVar = "something new"
? myObj.Process( pcMyVar) && returned value
? pcMyVar && something new, because it was not passed by reference
? myObj.cMyVar && something new

define class myObj as Custom
cMyVar=""
PROCEDURE Process( rcMyVar )
this.cMyVar = rcMyVar && this is going to assign the current value of the parameter to the property

rcMyVar = "altered value" && the value can be changed because 
return "returned value"
ENDPROC
ENDDEFINE
I use r as the prefix to indicate the parameter was passed by reference and can therefore be changed by the routine.

Now what exactly are you wanting to accomplish?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform