Tandy 1000 Basic Reference Manual page 174

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter 10 I
BASIC
Keywords
GOSUB
Statement
GOSUB
line
Branches to the subroutine beginning a t the specified line num-
ber.
Every subroutine must end with a RETURN. You can call a sub-
routine as many times as you want. When BASIC encounters a
RETURN statement in the subroutine, it returns to the state-
ment that follows the GOSUB.
GOSUB is similar to GOT0 in that it may be preceded by a test
st a t ement
.
Example
GOSUB 1 0 0 0
branches to the subroutine a t Line 1000.
Sample Program
2 6 0 GOSUB 2 8 0
2 7 0 P R I N T "BACK
FROM S U B R O U T I N E " :
END
2 8 0 P R I N T " E X E C U T I N G THE S U B R O U T I N E "
2 9 0 RETURN
transfers control from Line 260 to the subroutine beginning a t
Line 280. Line 290 instructs the computer to return to the
statement immediately following GOSUB.
172

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents