Transfers program execution to a label, with return option.
||Any valid label. The label name can be optionally followed by a colon (:)
statement is used to transfer execution to the line of code identified by label
. This label identifies an internal subroutine that is executed until a RETURN
statement is encountered. Execution then reverts to the line immediately following the GOSUB
Under the following circumstances control does not revert to the line following the GOSUB
statement: The internal subroutine invokes an ENTER
statement, or the internal subroutine terminates with an END
argument value corresponds to line of code identified by a label
identifier. Non-numeric labels end with a colon character; this colon is option when specifying the label
statement is similar to GOTO
, except that GOSUB
permits a RETURN
. The ON
statement provides a way to select one of several GOSUB
labels, based on an integer value.
jBASE emulation uses the ONGO.RANGE option setting for handling out-of-range label
The following example illustrates the use of the GOSUB
IF TIME()=0 THEN
PRINT "It's midnight, time is reset to 0"