Documentation Comments
Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.
RealityV15.1Online Documentation (MoTW) Revision 7
GOSUB Statement (DataBasic) (m618703+gosub_s.htm)
Transfers control to the subroutine with the specified label.
GOSUB statement-label
statement-label is the label of the statement where control is to be transferred.
GOSUB transfers control to a subroutine specified by statement-label, and execution continues sequentially from that statement until a RETURN statement is encountered.
The RETURN statement returns control to the statement immediately following the GOSUB statement that called the subroutine.
The RETURN TO statement returns control to a specific statement specified by statement-label.
If the GOSUB or a RETURN TO statement refers to a statement-label that does not exist, an error message is printed at compile time.
GOSUB statements can be nested with up to 199 levels of nesting possible.
10 GOSUB 30
15 PRINT X1
.
.
.
STOP
30 * SUBROUTINE
.
.
IF ERROR RETURN TO 99
40 RETURN
99 * ERROR RETURN HERE
Transfers control to statement 30. The subroutine is executed. If the logical variable error is true (1), the conditional RETURN TO 99 path is taken: otherwise, control passes back to the statement at label 15.