GoSub Command

Subroutine call. When you use the GoSub command, execution is transferred to the specified label and continues until a Return command is encountered, at which point execution returns to the command that follows GoSub.

Syntax

GoSub label

where label is defined by the Label command.

Remarks

Subroutines can be nested a maximum of 50 levels deep.

Example

'If the aircraft altitude is greater than 5,000, the print statement will execute and then the END statement will execute.

IF PLANE_ALT > 5000 THEN

GOSUB subAlt_5K

ENDIF

END

subAlt_5K:

PRINT "Altitude is greater than 5,000."

RETURN