Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unlimited number of parameters
Message
 
À
27/01/2005 13:51:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00981000
Message ID:
00981370
Vues:
45
>>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.
>
>Yes, I would do like that.
>
>>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.
>
>This can't be as this is the EXE entry parameters. This is launch from an icon.

Michele,

Another idea would be to launch the exe with only one parameter, which it would be a comma separated list of parameters, then in your main prg you only need one receiving parameter and some code to parse it, something like:

let's say this is your launching icon
some.exe "Some Char Parameter",SomeLogicalParameter,SomeNumericParameter,YouGetTheIdea
Then your main program would receive this list and parse it
lparameters tcParameterList && Unlimited (well almost)

local laParameters(1), lnParameterCount, lnParameter

if vartype(tcParameterList) = 'C'
   lnParameterCount = alines(laParameters, tcParameterList, ',')
else
   lnParameterCount = 0
endif

* Now in the array you have all the parameters, but all as character, so you convert them to their original type:
for lnParameter = 1 to lnParameterCount
    lcParameter   = laParameters[lnParameterCount] && an intermediate value
    if type(lcParameter) = 'U' && The parameter was just a character not between quotes
       laParameters[lnParameterCount] = tcParameter
    else
       laParameters[lnParameterCount] = evaluate(tcParameter)
    endif
endfor

* Now laParameters is an array with all parameters and their respective type
I just wrote the code in here without any testing whatsoever, just to give you a different idea
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform