|
Showing:
GOTO Commands
GOTO directs the flow of the batch file either on run-time decisions, or hard-coded flow. In a batch file, when command.com interprets the GOTO command, and the destination label is below the calling GOTO command, command.com can quickly jump to the label below the call, and execute the commands. However, if the label is above the calling GOTO, command.com must read to the end of the batch file, then start from the beginning, and read down until it encounters the label.
In GOTO statements, label names may well be wholly or partially variable. This can often simplify program flow control. For example, if you need to temporarily direct the flow from the main program to a generic, multi-use function, and then have flow return to the division point, you can implement the use of variable in the label name.
*
GOTO LabelName
[Arguments] |
[Constants] |
[Return Type] |
[Script Example]
|
Arguments
|
LabelName Name of a defined label within the running script.
|
|
Script Example
|
|
Unless otherwise noted, this code is licensed according to the terms and conditions listed
here. |
@echo off
:f1
set return=1
goto function
:r1
echo The function returned to R1
f2
set return=2
goto function
:r2
echo The function returned to R2
:f3
set return=3
goto function
:r3
echo The function returned to R3
goto end
:function
echo The function was called from F%return%
goto r%return%
:end
|
* This text may contain reprinted material from the
Microsoft
.
|