Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unlimited number of parameters
Message
 
 
À
26/01/2005 18:02:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00981000
Message ID:
00981254
Vues:
43
Hi, Fred.

>>I have an application that will receive an unlimited number of parameters. In VB.NET, I can have:
>>
>>
>>    Sub Main(ByVal CmdArgs() As String)
>>
>>
>>to define the entry parameters and have as much as I want.
>>
>>But, in VFP, I don't know if the same can be obtained. Is the only way to define, for exemple, up to 20 parameters, and verify each of them until I find one that is not passed? This approach would be like creating a long buffer of parameters in order to respond to an unlimited number of parameters being passed. Is that the only way or there is a VB.NET like mechanism?
>
>I don't know of any other way in VFP. All command line parameters to VFP will be passed as character, so you could use a naming convention and "build" your parameter name in a loop to check for the first one that contains a logical .F. for it's value. The one before that (eg: the last one that's of type character) is the last actual passed parameter.

Yes, you have to declare as much parameters as the maximum expected, but you can know the actual number of parameters passed by using pCount(). Checking for the first logical FALSE could be misleading because it could be a valid parameter.

Furthermore, if this is something beyond your control, you don't have other choice. If you can control the caller side, a better idea can be refactor this solution by introducing a parameter object, or maybe you already have an object with this data, and then you can pass it trough.

Hope this helps,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform