[SUB] (subroutine)
[SUB] defines processing that is reused as a single process block. Subroutines are not executed, even if they go through the processing path; subroutines are executed using the $GOSUB embedded function. This means that the subroutine must be defined before the $GOSUB embedded function is specified.
Syntax
[SUB] subroutine-name . . . [SUB_END] [BEGIN] . . . [SET_VALUE] $GOSUB(subroutine-name) [END]
Values
-
subroutine-name
Specifies the subroutine name. For the subroutine name, you can use alphanumeric characters and the underscore (_). However, a numeric character cannot be used as the first character of the subroutine name. Note also that case is considered significant in subroutine names.
Example
The following example defines a subroutine that outputs data to a Command Prompt window.
In this example, by specifying -s MSG=1 as an option in the jamscript command, the text set for ECHOMSG is output to a Command Prompt window:
[SUB] ECHO [IF] MSG = '1' [THEN] [SET_VALUE] $ECHO(ECHOMSG) [IF_END] [SUB_END] [BEGIN] [SET_VALUE] MSG = $GETSESSION('MSG') ECHOMSG = 'Hello world' $GOSUB(ECHO) [END] |