User`s manual

4-7
GOTO
line number
Transfers program control to the specified line number. Used alone, GOTO
line number
results in an unconditional (or automatic) branch; however, test
statements may precede the GOTO to effect a conditional branch.
Example:
200 GOTO 10
When 200 is executed, control will automatically jump back to line 10.
You can use GOTO in the Command Mode as an alternative to RUN. GOTO
line number
causes execution to begin at the specified line number, without
an automatic CLEAR. This lets you pass values assigned in the Command
Mode to variables in the Execute Mode.
See
IF,THEN,ELSE,ON … GOTO.
GOSUB
line number
Transfers program control to the subroutine beginning at the specified line
number and stores an address to RETURN to after the subroutine is
complete. When the Computer encounters a RETURN statement in the
subroutine, it will then return control to the statement, which follows
GOSUB.
If you don't RETURN, the previously stored address will not be deleted from
the area of memory used for saving information, called the Stack. The Stack
might eventually overflow, but, even more importantly, this address might be
read incorrectly during another operation, causing a hard-to-find program
error. So . . . always RETURN from your subroutines. GOSUB, like GOTO
may be preceded by a test statement. See
IF,THEN,ELSE,ON … GOSUB.
Example Program:
100 GOSUB 200
110 PRINT "BACK FROM SUBROUTINE":END
200 PRINT "EXECUTING THE SUBROUTINE"
210 RETURN
(RUN)
EXECUTING THE SUBROUTINE
BACK FROM THE SUBROUTINE