back to Command Reference
[All Models]
Returns execution from a subroutine to the main program.
RETURN
RETURN
RETURN statement is executed without first executing a GOSUB statement.Note: When a subroutine is called across program areas using GOSUB #n, the corresponding RETURN returns execution to the statement following the GOSUB #n in the original program area. The RETURN #n syntax is not used; cross-program-area returns are handled automatically by the return stack.
10 REM ***MAIN***
20 GOSUB 40
30 END
40 REM ***SUBROUTINE 1***
50 PRINT "SUBROUTINE 1";
60 GOSUB 80
70 RETURN
80 REM ***SUBROUTINE 2***
90 PRINT "SUBROUTINE 2"
100 RETURN
RETURN in line 70 returns to line 30, while line 100 returns to line 70.