Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The FUNCTION Command - deficiencies
Message
From
19/05/2002 19:06:58
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Product Documentation
Miscellaneous
Thread ID:
00658635
Message ID:
00658732
Views:
17
>I remember from school that when we called a function, it had to return to to the statement just after the "call". And, it had to return a value. I liked functions in the earlier xBase tools cause i didn't have to code a "DO". I could just line out the call (like a C call). At some point, VFP allowed me to call a proc just like a function. I liked procedures because they didn't have to return to the line after the call, they could spaghetti their way through the code, and did not need to satisfy the line after the call.
>
>In VFP 5, as I remember, if the function called was added to the form with the add method, the call required parantheses "MyForm.AddedFunction()", where as imbedded functions did not "MyForm.Show".
>
>Is there a difference (now) between a PROCEDURE and a FUNCTION? I know that some products use "function pointers" to allow in-line (re) assignments of methods that required a return value: "MyForm.MyButton.OnClick=SomeOtherClickMethod()"
>
>I would be interested in any differences between defining a snippet with FUNCTION as opposed to defining it with PROCEDURE.
>
>It seems you're indicating that the way VFP looks up a snippet name is dependant on the disignation as either a FUNC or a PROC?
>
>Is there a difference - or is the difference important in specific calling environments?
>
SNIP

Terry,

To my knowledge there is NO difference whatever between a PROCEDURE and a FUNCTION. A PROCEDURE can return a value and will return .T. in the absence ofa value, just ike a FUNCTION.
However, there is an important difference depending on HOW either is invoked.
Invoked through a DO, each PARAMETER is passed by reference unless enclosed in parentheses. So the command:
DO FuncOrProc WITH A1, (B2), C3
will have both A1 and C3 passed by reference and B2 passed by value.
To get the same through a function 'call' would take:
=FuncOrProc(@A1, B2, @C3)
and I believe that a method call works the same way.

As for method calls needing the parens or not, I'm not sure any more because I seem to occasionally get an error in VFP7 where I don't recollect similar in VFP6. So I now code parens on ALL my method calls, regardless.

Finally, I didn't mean to say that there is a difference in the LOOKUP of a name depending on whether it is a PROC or FUNC. Can you clarify how you interpreted such?

Cheers
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform