CIS 170 - Microcomputer Operating Systems
Professor. Edward F. Bouling, IV
With the majority of DOS commands, what you type after the command name is considered to be a command parameter. The command parameter is what the command will manipulate.
In addition DOS commands are flexible enough to allow you to change the command parameter to whatever you need it to be.
|Prompt||Command||Command parameter 1||Command parameter 2|
You can build the same type of flexibility into batch files by using replaceable parameters. DOS has 10 replaceable parameters, %0, %1, %2, %3, %4....%9. The work in your batch file the same way they work in DOS commands. They work by position. When you execute the batch file, DOS replaces the replaceable parameter with whatever you typed in after the batch file name.
%0 is the first parameter but its only used to hold the name of the batch file. %1 is used as the first parameter for the batch file, %2 is the second parameter, so on, and so on.
The below batch file is supposed to print any file that you enter in as its first parameter.
C\:> prnt autoexec.bat
The filename autoexec.bat will replace the %1 in the command copy %1 prn within the batch file, so now autoexec.bat is sent to the printer.
C\:> prnt Config.sys
The filename Config.sys will replace the %1 in the
command copy %1 prn within the batch file, so now Config.sys is sent to
Rem Demonstrating using replaceable parameters
echo The zero parameter is %0
echo The first parameter is %1
echo The second parameter is %2
echo The third parameter is %3
echo The fourth parameter is %4
echo The fifth parameter is %5
The first parameter is eat
The second parameter is at
The third parameter is joes
The fourth parameter is fine
The fifth parameter is foods
Lab exercises 1 and 2
Create the above batch files and execute them, experiment with them to see how replaceable parameters work.
Create a batch file that will
Clear the screen
Create the subdirectory colors within the other subdirectory (if you don't have an other subdirectory on your diskette make one)
Move you to the subdirectory colors.
Display the contents of the subdirectory colors.
Name the batch file Newdir.bat
Now make the Newdir.bat flexible enough so that you
can create a directory (with any name you want) within the other subdirectory,
and then be automatically moved to the newly created directory.
Make a copy for yourself and a copy to give me.