Dec 222017
 
Parse command line in QB4.
File WDMQ0110.ZIP from The Programmer’s Corner in
Category BASIC Language
Parse command line in QB4.
File Name File Size Zip Size Zip Type
-READ.ME 1286 682 deflated
PARSECMD.BAS 1049 550 deflated
PARSECMD.EXE 42323 30837 deflated
PARSECMD.LST 40895 5758 deflated
PARSECMD.OBJ 5064 2666 deflated
PARSECMD.SUB 5247 1862 deflated
PARSECMD.TXT 1883 767 deflated
TPCREAD.ME 199 165 deflated

Download File WDMQ0110.ZIP Here

Contents of the PARSECMD.TXT file



This text explains then method I use in my programs to parse the
program input parameters.

If there is only a ? given then a command summary is displayed.

The Parameters are compiled from three sources:
1. An evironment varible the same as the program name.
2. An ASCII file[s].
3. The command tail.

If the evironment variable begins with a + it is appended to the
command tail otherwise it is prepended. The result is then parsed.
If a parm file specification is incountered, (beginning with an @),
then the file contents are inserted into the command string in place
of the @ parameter. There can be multiple parm files used.

Strings can be enclosed with single (') or double (") quotes.
Either quote can be entered by enclosing it in the other. ("'")

Two consecutive switch characters will change the switch to the
next character. Example: sw is / then //- changes it to -.

Parameters which do not begin with the switch character are
counted and used in rotation. For example if the program accepts 2
non-switch parameters and the input is 'abc def ghi', then the result
would be the same as 'ghi def'.

EXAMPLES

GIVEN:

Program accepts 2 filenames and toggle switches.

File PARMA contains:
Filea /D
/Q

File PARMB contains:
Filed /e

Environment variable:
PROGNAME=/K FILEB

THEN:

Command line: PROGNAME filex /x
Would give : PROGNAME fileb filex /x /k

Command line: PROGNAME filex @parma /k
Would give : PROGNAME filea filex /d /q

Command line: PROGNAME @parma filex
Would give : PROGNAME filex filea /k /d /q

Command line: PROGNAME @parma @parmb
Would give : PROGNAME filed filea /k /d /q /e



 December 22, 2017  Add comments

Leave a Reply