GOSUB Verb

Syntax

GOSUB lineref

Description

The GOSUB verb transfers program control to an internal subroutine and branches unconditionally to the specified program line using the same logic as the GOTO.

Parameter

Description

lineref

Branch line number.

PRO/5 saves the location of the GOSUB on the FOR/GOSUB stack. To exit a subroutine, use a RETURN statement to return to the statement that follows the GOSUB. An EXITTO can also be used with a line number for the program to continue. Both RETURN and EXITTO pop the FOR/GOSUB/WHILE stack one level.

Examples

1000 GOSUB 2500

2500 REM SUBROUTINE
2510 LET A=50; LET B=A*C/2; PRINT B
2520 RETURN

See Also

Verbs - Alphabetical Listing