'Version: 1.0 of 4/17/91
'Author: Ken Prevo
'Purpose: Parse delimited COMMAND line to its component parts
' delimiter is the DOS delimiter '/'
'Copyright 1991 -- Ken Prevo, Lowell, IN
' May be used by anyone for any purpose as long as copyright notice remains intact
'if this is move from inline code to a sub, be sure to SHARE back to MAIN
IF COMMAND$ > "" THEN 'process the command into component parts and act on
'$DYNAMIC '/Fs compile to eliminate $ space entirely
REDIM Cmds$(9) 'up to 10 commands parsed -- change as needed
'note: if you are using PDQ Change subsequent COMMAND$ to x$ and uncomment next
'x$ = UCASE$(Command$) 'to keep QB compatibility.
IF LEFT$(COMMAND$, 1) <> "/" THEN
PRINT "First character in command line must be the '/' delimiter"
j% = 2 'pointer for valid first instring location
k% = -1 'count
DO 'count/process parts -- all parts are delimited by the standard slash
i% = INSTR(j%, COMMAND$, "/")
IF i% = 0 THEN i% = LEN(COMMAND$) + 2 'last parameter fix
IF i% > j% THEN 'we've got a param to parse
k% = k% + 1
Cmds$(k%) = RTRIM$(MID$(COMMAND$, j%, i% - j%))
j% = i% + 1
LOOP UNTIL j% > LEN(COMMAND$)
'k% holds number of items to process
FOR i% = 0 TO k% 'process all the commands first char holds command and remainder is passed data
PRINT i%; ": |"; Cmds$(i%); "|"
'normally can comment out the above print -- unless debugging
SELECT CASE LEFT$(Cmds$(i%), 1)
CASE "C", "c" 'set case insensitivity example--honor PDQ case
NotCaseSensitive% = -1
PRINT "Processing will disregard case"
'add your additonal case processing here and eliminate examples
'be sure to disregard first character command info using:
' Mid$(Cmds$(i%(2%)),2) to eliminate that character EG.
f$ = LTRIM$(MID$(Cmds$(i%), 2)) 'don't forget to blow away space
PRINT "Filename: "; f$
PRINT "Command Line Parsing failed on command parameter '"; LEFT$(Cmds$(i%), 1); "'"
'END 'uncomment out END when done with testing
ERASE Cmds$ '/Fs compile will fully erase, otherwise just data is gone.