Category : BASIC Source Code
Archive   : QBSUBS10.ZIP
Filename : PARSE.SUB

 
Output of file : PARSE.SUB contained in archive : QBSUBS10.ZIP
' PARSE.ASC -- MSDOS QuickBASIC subroutine parses COMMAND$ 25 June 86
' by David L. Poskie (608) 274-9560
' 7118 Raymond Rd. Madison, WI 53719
' Please run any suggestions, corrections, additions, or changes by me.
' I can be messaged on all the major Madison, WI RBBS's.

'| >>> OMNI.SUB and PARSE.SUB must be $Included in main program.
'| DIMensioning MUST be done in the main program; e.g.:
'| NumMax = 2 : DIM Cmd$(NumMax)
'| This would allow 2 commands (we ignore Cmd$(0) here).
'|
'| Function: Parse the command line tail, getting as many commands as exist
'| (up to the maximum set by the Cmd$(NumMax) dimension statement
'| in the main program).
'| Requires commands be separated by one or more
'| definable characters, (I use spaces here).
'| Input: NumMax = maximum number of commands this subroutine will parse
'| COMMAND$ = DOS command line function
'| Output: Num = the number of commands parsed.
'| Cmd$(1) to Cmd$(NumMax) = the separated command strings.
'| Other Vars: Text$ = internal work string
'| IsSep = flags the presence of a separator in Text$
'| Sep$ = one or more legal separators

Parse:
' We'll work with Text$ because COMMAND$ can't be altered
Text$ = COMMAND$
' Sep$ is the legal command separator (change as you desire)
Sep$ = " "
' Num = the number of command/s in the command line tail.
Num = 0
' Bail out on empty command line
IF Text$ = "" _
THEN GOTO ParseExit
' Bail out on non-alpha first character in command line
IF ASC(Text$) < 65 _
OR ASC(Text$) > 90 _
THEN GOTO ParseError
' We start filling Cmd$(Num)
' Look for from 1 to NumMax commands to put in Cmd$(Num)
Num = 1
ParseLoop:
' IsSep flags the occurrance & location of the first separator in Text$
IsSep = INSTR(Text$ , Sep$)
' If no separator, there is only this command left
IF IsSep = False _
THEN Cmd$(Num) = Text$ : _
GOTO ParseExit
' There is a separator, so get the command
IF Num =< NumMax _
THEN Cmd$(Num) = LEFT$(Text$ , IsSep - 1)
' If at our limit -- time to go
IF Num > NumMax _
THEN GOTO ParseExit
' Adjust Text$
Text$ = RIGHT$(Text$ , LEN(Text$) - IsSep)
' Adjust the count
Num = Num + 1
' Go filter any leading spaces or TABs in Text$
WHILE ASC(Text$) = 9 _
OR ASC(Text$) = 32
Text$ = RIGHT$(Text$ , LEN(Text$) - 1)
WEND
' Back for another command
GOTO ParseLoop
ParseError:
Text$ = "Non-alpha command . . ."
GOSUB Center
BEEP
ParseExit:
RETURN
' >>>>> Physical EOF PARSE.SUB 25 June 86


  3 Responses to “Category : BASIC Source Code
Archive   : QBSUBS10.ZIP
Filename : PARSE.SUB

  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/