GOSUB { [exp1,exp2,exp3,...expN] } int-exp

The GOSUB statement allows the execution of subroutines. The specific subroutine is specified by its starting line number - int-exp. Every subroutine must finish with a RETURN, otherwise a STACK OVERFLOW error will occur. The [exp1,exp2,exp3 ..... expN] construct allows the user to pass values TO the subroutine. These values are not passed back to the calling statement.

Program Example.

00100 INPUT A
00110 IF A <> 100 THEN GOSUB 1000 : GOTO 100
00120 PRINT "Execution Terminated"
00130 END : REM If this was not here, a STACK OVERFLOW would occur
01000 REM Subroutine to print out A
01010 PRINT "And A = ";A
01030 RETURN : REM RETURN to after the GOSUB i.e. GOTO 100

Try it

See also RETURN,ON..GOSUB