mercoledì 14 dicembre 2016

Funzione getOpt

Livecode 9 (dp3) contiene una nuova funzione: getOpt.
Questa funzione vi permette di avere la liste delle opzioni da riga di comando date in pasto al vostro programma.
Ad esempio se il vostro programma viene lanciato così:

mioProgramma.exe -v -s 10x10 -n Max --bello -z=51

potete cercare di estrarre le opzioni così:

put GetOpt("v s n b,bello z") into tInfo
if the number of elements in tInfo["errors"] > 0 then
   write "ERROR:" && tInfo["errors"][1] to stderr
else if "v" is among the keys of tInfo["options"] then
   put "l'utente ha scelto l'opzione v"
else if "s" is among the keys of tInfo["options"] then
   put "s = " tInfo["options"]["s"]
else if "n" is among the keys of tInfo["options"] then
   put "n = " tInfo["options"]["n"]   
end i

Per più informazioni leggete: http://livecode.wikia.com/wiki/Getopt

Nessun commento:

Posta un commento