Last Name                                                                First Name

Date                                                                           Class Night
 
 

CIS 170 - Microcomputer Operating Systems

Professor. Edward F. Bouling, IV
 
 


Chaining Versus Calling

Chaining is when you execute the commands within one batch file and then immediately start to execute commands of second batch file. When the all the commands of the second batch file are finished executing the DOS prompt is displayed.

Calling is when execute the commands within one batch file pause and tell a second batch file to execute the commands within it. When all the commands of the second batch file are finished executing the first batch file resumes executing its commands.

Original.bat

ECHO OFF

ECHO Starting the First Batch Program

ECHO.

ECHO Display all the Directories on the C drive

ECHO.

DIR *.

ECHO Starting the Second Batch Program

ECHO.

NextOne

ECHO Should be back in the Original.bat

ECHO.

ECHO If so show me a sorted directory

ECHO.

DIR /o

ECHO End of Original.bat

NextOne.Bat ECHO OFF

ECHO.

ECHO I'm in the next Batch Program now what

ECHO Press a key and go back

PAUSE

ECHO Goodbye

If you execute original.bat the way it is typed in, when execution reaches the line with the name of the second batch file (nextone.bat) control will pass from original.bat to nextone.bat. After all of the commands in the second batch file (nextone.bat) have been executed control will be passed back to DOS. In other words the DOS prompt will be displayed.

Experiment with these two batch files by executing them the way they are now and then change line 11 (nextone.bat) to call nextone.bat.

  Make a copy for yourself and a copy to give me.