Hardware Reference
In-Depth Information
If you wish to view the batch file which you have just created simply enter the
command:
TYPE ARCHIVE.BAT
Whenever you wish to execute the batch file simply type:
ARCHIVE
Note that, if necessary, the sequence of commands contained within a batch file
may be interrupted by typing:
<CTRL-C>
(i.e. press and hold down the CTRL key and then press the C key).
The system will respond by asking you to confirm that you wish to terminate
the batch job. Respond with Y to terminate the batch process or N if you wish
to continue with it.
Additional commands can be easily appended to an existing batch file. As
an example, assume that we wish to view the directory of the disk in drive A:
after running the archive batch file. We can simply append the extra commands
to the batch files by entering:
COPY ARCHIVE.BAT + CON:
The system displays the filename followed by the CON prompt. The extra line
of text can now be entered using the following keystrokes (again with each line
terminated by <ENTER> ):
DIR A:\
<CTRL-Z>
Passing parameters
Parameters may be passed to batch files by including the % character to act as a
place holder for each parameter passed. The parameters are numbered strictly
in the sequence in which they appear after the name of the batch file. As an
example, suppose that we have created a batch file called REBUILD, and this
file requires two file specifications to be passed as parameters. Within the text
of the batch file, these parameters will be represented by % 1 and % 2. The first
file specification following the name of the batch file will be %1 and the second
will be %2 . Hence, if we enter the command:
REBUILD PROC1.DAT PROC2.DAT
During execution of the batch file, %1 will be replaced by PROC1.DAT whilst
%2 will be replaced by PROC2.DAT.
It is also possible to implement simple testing and branching within a batch
file. Labels used for branching should preferably be stated in lower case (to
avoid confusion with operating systems commands) and should be preceded
by a colon when they are the first (or only) statement in a line. The following
example which produces a sorted list of directories illustrates these points:
@ECHO OFF
IF EXIST %1 GOTO valid
Search WWH ::




Custom Search