REM===================================================================== REM REM Program : PARAMETERS REM Purpose : Tests PROCparameters REM Author : Ian Giblin, (c) 1996 REM REM===================================================================== ON ERROR PRINT REPORT$;" at line ";ERL:END DIM word$(10) wordcount% = 0 PROCparameters(word$(), wordcount%) PRINT '"Progname : "word$(0) IF wordcount%>0 THEN FOR w%=1 TO wordcount% PRINT "Parameter ";w%;" : ";word$(w%) NEXT w% ENDIF PRINT END REM===================================================================== REM REM Procedure : PARAMETERS REM Purpose : Simplistic way to get the command line parameters REM Notes : Needs word$() and wordcount% to exist a priori. REM wordcount% is the number of *parameters*, maybe zero. DEFPROCparameters(RETURN word$(), RETURN wordcount%) LOCAL debug, c$, b$ , w% leader$ = "BASIC -quit " debug = FALSE SYS "OS_GetEnv" TO c$ IF LEFT$(c$, LEN(leader$))<>leader$ THEN PRINT'"Error from PROCparameters: Leader is not "+CHR$34+leader$+CHR$34 PRINT'"The full command line is: "+c$ PRINT'"You need to edit the program (or your sysvars!)."' END ENDIF c$ = RIGHT$(c$, LEN(c$)-LEN(leader$)) + " " WHILE INSTR(c$,CHR$(34))>0:MID$(c$,INSTR(c$,CHR$34))=" ":ENDWHILE IF debug THEN PRINT "c$="+CHR$34+c$+CHR$34 WHILE LEFT$(c$,1)=" ":c$=RIGHT$(c$,LEN(c$)-1):ENDWHILE IF debug THEN PRINT "c$="+CHR$34+c$+CHR$34 w% = 0 WHILE LEN(c$)>0 b$ = "" WHILE LEFT$(c$,1)<>" " b$ = b$+LEFT$(c$,1) c$ = RIGHT$(c$,LEN(c$)-1) ENDWHILE WHILE c$<>"" AND LEFT$(c$,1)=" ":c$=RIGHT$(c$,LEN(c$)-1):ENDWHILE IF debug THEN PRINT "c$="+CHR$34+c$+CHR$34+" word(";w%;") = "+b$ word$(w%) = b$ w% += 1 ENDWHILE wordcount% = w%-1 ENDPROC