Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Global variable dies when sent as a parameter??
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00179903
Message ID:
00180217
Views:
29
>It's been a while since i looked, but as i recall, SET UDFPARMS only applies when invoking a procedure as a FUNCTION, not via DO...WITH. My reading of the documentation in VFP 6 under remarks is that DO...WITH always passes by reference: A quote from the docs:
>
>Remarks
>
>By default, variables are passed to a user-defined procedure by value. (Variables passed to procedures with DO ... WITH are passed by reference.)
>
>italics added by me. The gist of the doc is that there is a clear distinction made in the behavior of a UDF and a procedure, and SET UDFPARMS appears to only apply to invocation of UDFs. That follows the behavior I see. An array passed to a procedure by DO...WITH is always by reference, and there's no way to override the behavior of DO...WITH to force pass by reference (in a function, you can force by reference by prefixing with @; this construct is not available to DO...WITH). There is a means of overriding to pass by value by enclosing the argument in parentheses, so that the argument is treated as an expression and the result of the expression is passed.
>
>I realize that may not be how you'd like it, but there's an easy fix here - just force the pass by value in DO...WITH by enclosing in parentheses. If you need to pass by reference to get returns from side-effects, then don't use a PUBLIC; hopefully, you can see the problems that would be created if the same chunk of data could be altered by two different name references (VFP uses a type of indirection, where there's a table of names of things that point to value references; if the variable is updated, the value reference can be replaced by a different one in the name table. If one reference were changed, how would you know to update the other variable reference's value pointer, so that things would't get very confused very quickly.
>
>Ed

Thanks!!!

This si EXACTLY the info I needed. Of cource I missed that line in the help file.

Thanks again...
(using VFP 3.0 for Win & Mac)
Previous
Reply
Map
View

Click here to load this message in the networking platform