RETURN - Return from a subroutine in a batch file
Purpose: Return from a GOSUB (subroutine) in a batch file.
Format: RETURN [value ]
value : The exit code from 0 to 255 to return to the command
processor or to the previous batch file.
See also: GOSUB.
Usage
CMD.EXE allows subroutines in batch files.
A subroutine begins with a label (a colon followed by a word) and ends
with a RETURN command.
The subroutine is invoked with a GOSUB command from another part of the
batch file. When a RETURN command is encountered the subroutine
terminates, and execution of the batch file continues on the line
following the original GOSUB. If RETURN is encountered without a GOSUB,
the command processor will display a "Missing GOSUB" error.
The following batch file fragment calls a subroutine which displays the
files in the current directory:
echo Calling a subroutine
gosub subr1
echo Returned from the subroutine
quit
:subr1
dir /a/w
return
If you specify a value, RETURN will set the ERRORLEVEL or exit code to
that value. For information on exit codes see the IF command, and the %?
variable.
Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs