Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Anything better than PCOUNT()?
Message
De
04/11/2015 15:00:33
 
 
À
04/11/2015 14:32:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01627034
Message ID:
01627037
Vues:
86
>Hi,
>
>I think I know the answer to this but wanted to see if there really is a solution:
>
>I want to use a method with a few of the parameters as optional e.g.
>
>
>loSettings.SetObject("txtLastname",,.T.,.F.)
>
>
>and then in the method code I have this:
>
>
>LPARAMETERS tcObjectName, txValue, tlVisible, tlEnabled
>
>
>where the 2nd parameter is not passed; PCOUNT() does not does help because I have passed the 3rd and 4th params.
>
>Of course in the method code, I get a default value for the second parameter as .F.; but that does not help me to know if it was passed or not because in this case the "value" could be a logical that was passed.
>
>I realize that I could change the order of the parameters so that txValue is last and then PCOUNT() works but the 2 most commonly used parameters are the first 2 and so I would rather have them in the order they are.
>
>What I need is function that tells me if the 2nd paramter ws passed something like IF PARAMETER(2) = .T.
>
>or I need a way for the parameters to default to .null. or something if nothing passed.
>
>Am I missing something that is in the help file?

No, as far as I know that's all there is. IMO optional parameters are kind of a pain in VFP; they're not well or clearly supported as with languages that support overloading.

For this kind of reason, and for future maintainability I prefer to always pass all the parameters. Some of them can be set to .NULL. in the call, and in the method you can do
IF ISNULL( m.luParamX )
  ...
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform