
Chapter
Statements
1
1
11 -34
Use the RETURN statement to return control to the statement following
the most recently executed GOSUB (page 11 -13). Use one return for each
GOSUB to avoid overflowing the control stack. This means that a
subroutine you call with the GOSUB statement can call another subroutine
with another GOSUB statement.
Syntax
RETURN
Example
Simple Subroutine
>1
REM EXAMPLE PROGRAM
>
10 FOR I = 1 TO 5
>
20 GOSUB 100
>
30 NEXT I
>
40 END
>
100 PRINT I
>
110 RETURN
READY
>RUN
1
2
3
4
5
Nested Subroutine
>1
REM EXAMPLE PROGRAM
>
10 FOR I = 1 TO 5
>
20 GOSUB 100
>
30 NEXT I
>
40 END
>
100 PRINT I,
>
110 GOSUB 200
>
120 RETURN
>
200 PRINT I*I,
>
210 GOSUB 300
>
220 RETURN
>
300 PRINT I*I*I
>
310 RETURN
READY
>RUN
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
RETURN
Comentarios a estos manuales