Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unlimited number of parameters
Message
 
À
27/01/2005 16:13:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00981000
Message ID:
00981502
Vues:
67
"D:\Visual FoxPro Projects\DMIB FoxRun\main.exe" "D:\visual foxpro projects\dmib foxrun\PRG\fact_xls.prg,2004\01\01,2004\12\31,M ET M,metm.xls" "/LOG"
>
>In this case, we are calling D:\visual foxpro projects\dmib foxrun\PRG\fact_xls.prg for the PRG which expects to receive 2004\01\01, 2004\12\31, M ET M, and metm.xls as parameters. So, what I did was to put all that in quotes. The first one is the PRG and it always there. If I have a second parameter and so on in that quote, that means the PRG will expect those parameters. So far so good but I need a bunch of other optional parameters such as /LOG which accepts a log file as a parameter and /GUI, etc. So, the proposed approach I have thought would make sense is to keep the current first quoted parameter as is which handles the PRG and its parameters. Then, I would pass another quoted parameter for all the switches.

I still think you can parse it with a code similiar to what I posted, the call would be:
"D:\Visual FoxPro Projects\DMIB FoxRun\main.exe" "D:\visual foxpro projects\dmib foxrun\PRG\fact_xls.prg,2004\01\01,2004\12\31,M ET M,metm.xls","/LOG"
When you parse it, you'll end up with to elements in the array:

laParameters[1] = "D:\visual foxpro projects\dmib foxrun\PRG\fact_xls.prg,2004\01\01,2004\12\31,M ET M,metm.xls"
laParameters[2] = "/LOG"

or, if you had more parameters:
"D:\Visual FoxPro Projects\DMIB FoxRun\main.exe" "D:\visual foxpro projects\dmib foxrun\PRG\fact_xls.prg,2004\01\01,2004\12\31,M ET M,metm.xls","/LOG","/GUI","/ADMIN"
laParameters[1] = "D:\visual foxpro projects\dmib foxrun\PRG\fact_xls.prg,2004\01\01,2004\12\31,M ET M,metm.xls"
laParameters[2] = "/LOG"
laParameters[3] = "/GUI"
laParameters[4] = "/ADMIN"

Then you can take the appropiate actions like
if lnParametersCount = 0
  * Do something
else
  lcCmd = "RUN " + laParameters[1] && or strtran(laParameters[1], ',', ' ')
  if ascan(laParameters, '/GUI', 2)
      * /GUI passed as parameter
  endif
  if ascan(laParameters, '/Log', 2)
      * /Log passed as parameter
  endif
etc. I do not know exaclty what you want to do with the parameters, but I think somethink like that should work


One thing I think we forgot to mention (or I am just plain wrong :) is that the list of parameters can not be unlimited for it is limited (or I think it is) to a limited string length, so you might run into problems if
"D:\Visual FoxPro Projects\DMIB FoxRun\main.exe" "D:\visual foxpro projects\dmib foxrun\PRG\fact_xls.prg,2004\01\01,2004\12\31,M ET M,metm.xls","/LOG"
gets too long. I wrote long time ago a messaging program, where one of the parameters was the message, but if the message was longer than something I forgot, then it failed, so I ended up using an extra parameter that was a flag indicating that the message was a file instead of a message, if I needed a long message
"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