Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to store form related procedures
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00247602
Message ID:
00247613
Views:
24
>I have a form with a procedure that needs to be called from multiple places within the same form. If I place the procedure in a procedure file I can no longer make "thisform" type refrences. Where can I store this procedure so that it is considered part of the form?
>

Create a new method of the form and invoke it rather than a procedure; IOW, if you now reference your procedure by:

DO MyProc

You could create a method of the form called MyMethod, and invoke it as:

thisform.MyMethod

Methods operate like functions in that they can return a value if you need them to, and like both procedures and functions can accept parameters. If you now invoke your procedure by

DO MyProc WITH "one potato", Date()-42, SomRandomCVariableRef

your method would be invoked by:

thisform.MyMethod("one potato", Date()-42, SomRandomCVariableRef)

A method behaves more like a function call, in that values passed to a method are passed by value rather than by reference. If you pass a variable into a method call and must have the value altered in the method, you must prefix the it with the @ qualifier to tell VFP to pass by reference. If you pass a variable to your procedure, which changes it, and you want that value changed, invoking it via DO now would look like:

Do MyProc WITH SomeVariableToChange

Invoking MyProc as a function would require the @ prefix, like a method call would:

=MyProc(@SomeVariableToChange)

You'd use the same technique to pass by reference to your method:

thisform.MyMethod(@SomeVariableToChange)

If instead, you invoke the method without the @ prefix, the variable will be passed by value, so that any changes to the value will not affect the original copy:

thisform.MyMethod(SomeVariableToChange)

>Marvin
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
Reply
Map
View

Click here to load this message in the networking platform