Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Advantage and disadvantage of funct PRG
Message
De
01/12/2017 15:44:23
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01656009
Message ID:
01656012
Vues:
92
>Hi,
>
>Say I have a function that I want to put into a separate PRG file. I can do it without declaring the FUNCTION FunctName within the PRG file. And then call this PRG name as a function. E.g.
>
>do MyPrgName with tParam1, tParam2
>
>
>If I add a FUNCTION FuncName then I would have to do SET PROCEDURE to MyPrgMane ADDITIVE (somewhere at the top of the app) and then call it as
>
>FuncName( tParam1, tParam2)
>
>
>What are the advantages or disadvantages of having the function inside a PRG without the FUNCTION declaration?
>
>TIA

If I'm not mistaken, you can call a standalone PRG like invoking a UDF.

for example if we have MYFUNC.PRG containing the following
PARAMETERS n1,n2
RETURN m.n1 + m.n2
you should be able to invoke it as:
? myfunc(1,2)
Aside from the main difference where calling it as a function allows you to return a value, there is the subtle difference parameter passing. IIRC, calling like a procedure tends to favor pass-by-reference while calling like function is affected by SET UDFPARM setting. Of course you could put parenthesis around parameter to force pass-by-value (except for object types). In calling like function you can specify pass-by-reference by prefixing parameter with "@".
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform