Commodore PC Ms-Dos 3.2 User's Manual page 178

Table of Contents

Advertisement

1106 MS-DOS User's Reference
How to Create a Batch File
with Replaceable Parameters
There may be times when you want to create a program and run
it with different sets of data. These data may be stored in various
ms-dos files.
^
)
With ms-dos you can create a batch {.bat) file with replaceable
(dummy) parameters, where a. parameter is a command option
that you define. These parameters, named %0-%9, hold the places
[^J
for the values that you supply when you give the batch command.
Replaceable parameters make batch files more flexible and easy to
use. For example, you can create a batch file called sorter.bat that
^ )
sorts a file containing a specific sequence of characters or strings.
Each time you execute the sorter batch file, you tell ms-dos which
string you want, which file to search to find that string, and which
\)
temporary file to use for sorting. Sorter would then print the
resulting list on the printer.
Using replaceable
ED To create the sorter.bat file, type the following command and
\~s
parameters
then press the return key:
copy
con
50rter.bat
ii
[2] Now type the following lines:
type %2 ! find "%1" > %3
^
type
%3
1
sort
>
prn
del
%3
[U To save the batch file, press control-z and then return.
The batch file sorter.bat now consists of three command lines
and is on the disk in the default drive.
\^J
When you execute the file, ms-dos sequentially replaces %/, %2,
i
\
and %3 with the parameters you supply. If you use the dummy
^-^
parameter %0, ms-dos always replaces it with the drive name (if
specified) and the filename of the batch file (for example, sorter).
Notes
■ You can specify up to ten replaceable parameters (%0 — %9).
^-^
If you want to specify more than ten, refer to the shift com
mand later in this chapter.
■ If you use the percent sign as part of a filename within a
^—^
batch file, you must type it twice. For example, to specify the
file abc%.exe, you must type it as abc%%.exe in the batch file.

Advertisement

Table of Contents
loading

Table of Contents