SUBROUTINES

One BATCH file can execute another, complete with values to be substituted 
for the replaceable parameters of the called BATCH file. Programs can also
execute BATCH files. Environment variables can be passed as values, or 
referenced directly from the DOS environment space by the called BATCH file. 
A BATCH file name can even be passed as a value to the called BATCH file. 
A BATCH file can call itself without getting into a loop, if it is careful 
how it exits. BATCH files can be either CHAINED or NESTED.

	CHAINED	BATCH file			NESTED BATCH file

When one BATCH file chains to another	When one BATCH file executes another
BATCH file to execute it, so that the	BATCH file by calling it as a sub-
first BATCH file ceases processing,	routine, so that when the called BATCH
and all BATCH file processing ceases	file terminates, the calling BATCH
when the second BATCH file terminates.	file resumes execution just after the
					call to the subroutine.

CHAINED execution:			NESTED execution:
If A executes B by:			If A executes B by:
    some commands			  some commands
    .					  .
    .					  .
    .					  .
    B [value1 ... [valueN]]		  COMMAND /C B [value1 ... [valueN]]
    .					  .
    .					  .
    .					  .
    some more commands			  some more commands
then no matter what follows in 		then when B terminates, A will resume
    A, it will not be executed.		  executing with the next command after
    When B terminates, it will		  the execution of B. Any changes to
    return to whatever called A.	  environment variables made by B will
    Variables changed by B will		  be lost on EXIT. A will see the 
    remain changed.			  values that existed when B was 
					  called. In DOS 3.3 and later, CALL
					  can be used instead of COMMAND /C.

Nested BATCH files terminate in one of two ways: 
    explicitly by executing an EXIT command anywhere in the file.
    implicitly by executing the last command in the BATCH file. 

Chained BATCH files terminate in one of two ways:
    if the first link of the chain was executed directly from the keyboard,
	by executing the last command in the BATCH file 
    if the first link of the chain was a nested BATCH file called "X",
	like a nested BATCH file (see above), and "X" will also be EXITed.

EXPLICIT EXIT:                       IMPLICIT EXIT
    some commands                       some commands                  
    (including skipped EXITs)		(including EXITs, skipped or not)
    .                                   .
    .                                   .
    .                                   .
    EXIT                                last command (which may be EXIT)
    (the BATCH file terminates here)
    .
    .
    .
    some more commands 
    (including skipped EXITs)
An EXIT command which is skipped over by a GOTO or is the command on an IF 
statement that evaluates as FALSE will not terminate a BATCH file.
