Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Defaulting parameter to null
Message
De
19/09/2019 17:45:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
19/09/2019 14:17:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01670958
Message ID:
01670969
Vues:
78
>Hi all,
>
>I am going to myself guess that the answer to this next question is a "no" based upon my testing but just in case I am wrong here goes...
>
>- can a parameter default to null if not passed to a function or procedure e.g.
>
>
>LPARAMETERS tlUseExistingServer
>
>
>I tried
>
>
>LPARAMETERS tlUseExistingServer AS BOOLEAN NULL
>
>
>But that just lets me store .null. to the parameter after it has been passed. I know you can use PCOUNT() or PARAMETERS() to test if something passed but that does not work so well if you want to pass *some* parameters but not others and you still want to know if something has been passed or not.
>
>Thanks,
>Albert

You can do that indirectly without using pcount() or parameters() (I seldom use them). When you don't pass a parameter, by "default" it is boolean false or simply empty() - in VFP .F. is empty.
Thus you could do this:
parameters tuSomeParameter
*tuSomeParameter = evl(m.tuSomeParameter, < valueYouwantAsDeafult >)
tuSomeParameter = evl(m.tuSomeParameter, .null.)
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform