Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Function vs Procedure
Message
De
22/06/2002 08:32:33
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00671285
Message ID:
00671334
Vues:
14
There has been some incorrect information given in this thread.

A function optionally returns a value, while a procedure does not return a value. In most languages, the difference is specified in how you declare the subroutine. If you declare it a FUNCTION, it is always a function. If you declare it a PROCEDURE, it is always a procedure. However with VFP, I can use either FUNCTION or PROCEDURE.

When you make the call as a procedure, such as:
DO MyProc WITH Parm1, Parm2
I would not get a return value. The parameters, by default, are passed by reference. To pass Parm1 by value, I would make the call:
DO MyProc WITH (Parm1), Parm2
<pre>

If I make the call as

<pre>
RetVal = MyProc(Parm1, Parm2)
the parameters are passed by value. To pass Parm1 by reference, the call would look like:
RetVal = MyProc(&Parm1, Parm2)
The function may or maynot return a value. If you don't specify a return value in the function code, it will return .T. I can also ignore any return value and make the call like this
MyProc(Parm1, Parm2)
Finally, you can change the way parameters are passes with SET UDFPARMS. Note this is a global setting.

>Hi Mike
>
>Even more devious.
>
>I assume
>
>
myProcedure(param)
>
>also passes variables by reference then or is this only when using the DO ... WITH form
>
>Regards
>Geoff Scott
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform