Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing form properties by reference to a procedure
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00162339
Message ID:
00162382
Views:
22
>I am porting a FPW2.6 application to VFP.
>I encountered some (to me) strange behaviour.
>I have my SET UDFPARMS set to Value.
>I then call a methof from within a form something like.
> Do myprocedure with thisform.prop1, thisform.prop2
>
>In the myprocedure procedure the passed arguments contents are changed.
>But on returning to the calling form method the contents of the passed arguments are empty again.
>
>If I store the contents of the formproperties into some local defined memory variables and pass on these to myprocedure the changed contents are visible in the calling form method.
>
>Why is Fox behaving different?
>Normally by default arguments are passed to procedures by reference, or is this different when the passed arguments are refering to object properties.??
>And in fact I don't want to store the object properties into local variables pass them to the method and storing them back again to the object properties.
>I know this is not the ideal situation (point of view encapsulation etc..). But you know I'm in a hybrid application moving it slowly to the ideal visual environment. One step at the time.

Hi Yves,

A couple of things to note. First, DO < procedure name > WITH always, regardless of the setting of UDFPARMS, passes the parameters by reference. UDFPARMS only effects calls such as: result = FunctionName(parameter). This was true back in 2.x (see Help under SET UDFPARMS).

In VFP, however, objects are always passed by reference, regardless of what they're passed to.

hth,
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform