SpartaDOS X Reference Manual

The Command Processor — Advanced Features




The Command Processor — Advanced Features

Index


Batch Files  

Batch files are simply a list of SpartaDOS commands that may be fed to the command processor from a text file. Parameters may be passed to the batch file by including them on the command line following the batch file name. The syntax is

    -fname [parm1 parm2 ... parm9]

The filename ("fname") is assumed to have an extension of ".BAT" although this assumption may be overridden by including an extension on the command line. The parameters ("parm") are optional.

The following is an example of a batch file which accepts two files on input and creates an output file containing the contents of both source files (we will call this file "TEST.BAT").

    COPY %1 %3

    Copy %2 %3/A

Now, the command

    -TEST FILE1 FILE2 OUTPUT

will concatenate the files "FILE1" and "FILE2" to the file "OUTPUT".

You may pass up to 9 parameters (numbered "%1" to "%9") to a batch file. The parameter "%0" is the name of the batch file (in the above case, this would be "TEST"). The '%' parameters may appear anywhere in the batch file and may be surrounded in text (i.e. no spaces need precede the '%' character).

The batch file parameters are automatically saved in environment variables "_x1" where 'x' is the parameter number. Due to the command processor's non-resident nature, the parameters need to be saved somewhere — environment variables are a perfect place. This also means that the number and size of parameters is limited to a total of 256 characters less overhead (the "_x1=" string) and space used by other environment variables.


Previous page

Next page