Mark Wickens

RETURN

Purpose

Returns execution from a subroutine to the main program.

Format

RETURN

Example

RETURN

Explanation

  1. Returns program execution to the statement immediately following the statement which originally called a subroutine.
  2. A GS error is generated when the RETURN statement is executed without first executing a GOSUB statement.

See

Sample Program

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 120 returns to line 20, while line 210 returns to line 110.