Category : BASIC Source Code
Archive   : QBCMDLN.ZIP
Filename : PARSECMD.BAS

 
Output of file : PARSECMD.BAS contained in archive : QBCMDLN.ZIP
'Program: PARSECMD.BAS
'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
'$STATIC
'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"
END
END IF
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
END IF
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.
CASE "F"
f$ = LTRIM$(MID$(Cmds$(i%), 2)) 'don't forget to blow away space
PRINT "Filename: "; f$
CASE ELSE
PRINT "Command Line Parsing failed on command parameter '"; LEFT$(Cmds$(i%), 1); "'"
'END 'uncomment out END when done with testing
END SELECT
NEXT
ERASE Cmds$ '/Fs compile will fully erase, otherwise just data is gone.
END IF





  3 Responses to “Category : BASIC Source Code
Archive   : QBCMDLN.ZIP
Filename : PARSECMD.BAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/