GOSUB
[/?]
label
/?The GOSUB command is only valid within command scripts. It calls as a subroutine the line in the current command script that immediately follows the specified label.
The label name supplied must exactly match, except for case, the label in the script. All characters in the name are significant, spaces count, and the label name may contain any number of words. This is different to the 16-bit CMD supplied with IBM OS/2, where only the first 8 characters are significant, and where spaces or full stop characters terminate the label and cause any further characters to be ignored.
The return value of the GOSUB command is the value of the error level when the subroutine returns, usually the value passed to the RETURN command that ended the subroutine. A subroutine also returns implicitly when the end of the script is reached during its execution.
Any redirections applied to the GOSUB command apply to the entire subroutine that is called, and remain in force, unless overridden, throughout its execution.
Note: Because the left-hand side of a pipeline is executed in a child command interpreter process, it is not executed in the context of a command script and a GOSUB command will fail. The output of a subroutine cannot therefore be redirected through a pipe.
CALL EXTPROC FOR GOTO RETURN CANCEL QUIT EXIT