>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