Revised and reorganized June 2020
Arguments $0 through $9
The formal arguments $0 through $9 within the DO file are replaced by the first through tenth space-delimited tokens on the command line that invokes the DO file, with the first token being the one following the name of the DO file itself on the command line. Thus, if the command line was:
DO MAIN 22 GL
then $0 will be replaced by "22" and $1 by "GL". This differs from Windows (which uses %0 through %9) and Unix (which uses $0 through $9), both of which use the zero parameter to refer to the name of the batch or script file itself rather than the first user argument.
Since the space is used as a token delimiter, a special trick is needed to create a single argument that contains a space. Angle brackets may be used for this purpose to combine multiple tokens into a single argument. For example, in the following command line:
DO MAIN 22 <GL OPTION1 OPTION2>
"GL OPTION1 OPTION2" will be treated as $1.
In addition to the literal text arguments just described, DO also accepts file-based variable arguments using the syntax ++fspec, which get replaced at execution time by the contents of the first line of the file specified by fspec.
For example, if the first line of the file mydata:c.txt contained "THIS DATA", then the DO file command line:
DO MAIN 22 ++MYDATA:C.TXT
would expand to:
DO MAIN A B <THIS DATA>
The <brackets> are employed when the line contains embedded spaces so that the entire line is treated as a single argument.
Note that "DO" in the above examples is optional and included only for clarity. It is only needed when the filespec argument following it (e.g. "MAIN") is ambiguous, i.e. when it might refer to SYS:MAIN.LIT or cmd:main.cmd rather than cmd:main.do.
Default Arguments
To establish default values for arguments which are not specified on the command line, the DO file can begin with the special command $D followed by the defaults for $0, $1, etc. Arguments not specified in this list will have no default. You can also specifically skip over a default argument by inserting just a $ in the argument’s position on the $D line. For example:
$D DEF0 $ DEF2
This would set the default for $0 to "DEF0", the default for $1 to nothing, and the default for $2 to "DEF2".
The $D command, if present, must be on the first line of the DO file.