# GOSUB

Syntax:

Then: GOSUB "label"
If: ...
Then: ...
label If: subroutine
Then: ...
If: ...
Then: subroutine
Then: RETURN

Version Ref: 3.x

Description:

"label" is a subroutine of code, terminated with a RETURN, that GOSUB calls.
RETURN ends the subroutine started at "label" by GOSUB, and starts processing
up again at the command after GOSUB.

Processing will immediately branch to "label" and start executing from that point until a RETURN is encountered, at which time processing returns to the command immediately after the GOSUB. If there is a ";" after this GOSUB label, the command after the ";" is executed next. Otherwise, processing will pick up again at the "if" line immediately below "GOSUB label".

IMPORTANT: You must end all subroutines with a RETURN. Do not send processing to a subroutine with GOSUB and have it encounter an END statement before it encounters a RETURN. This may work in many cases but is not a good practice and can cause erratic results.

Note: Maximum number of nested GOSUBs (GOSUBs that are called by other GOSUBs) is 16 per table.

Command used with GOSUB: