Gosub – Visara Master Console Center Scripting Guide User Manual
Page 124
Chapter 5 Script Commands
Scripting Guide
124
GOSUB
Syntax:
GOSUB *Label
Description:
Immediately transfers script execution to the specified label, and waits
until the called routine finishes execution.
Action:
Script execution is transferred to the specified label and continues
normal script execution until the RETURN statement is encountered.
At that point, script execution continues with the statement
immediately following the GOSUB statement.
Parameters:
*Label. Label literal. Name of the label to transfer execution to.
Returns:
N/A.
Notes:
1. The label must be in the current script.
2. Nesting of GOSUBs is allowed and encouraged for good script
structure and organization. The maximum number of nested
GOSUBs is 255.
3. The major difference between GOSUB and GOTO is:
-
GOSUB is used to execute a subroutine, wait until it is done, and
then continue processing (perhaps by calling another subroutine).
-
GOTO is used to immediately transfer the flow of script execution
to another step. There is no returning as with the GOSUB
command, and therefore is no nesting of GOTOs.
Example:
*START:
GOSUB *LABEL01
//calls a subroutine in the
//same
script
file
RETURN //done
with
this
script,
//so
let’s
return
to
whatever
//called
us
*LABEL01:
// do some good things here...
RETURN
//continues with the next
//statement
after
the
GOSUB
See Also: