Chapter
10
I
BASIC
Keywords
GOTO
Statement
GOTO
line
Branches
to
the specified
line.
When used alone, GOTO results in an unconditional branch.
However, test statements, such as IFITHEN, may precede the
GOTO
to
effect a conditional branch. Note that the GOTO is op-
tional in IFiTHEN statements. For example:
IF
X=O
THEN 360 ELSE 200
BASIC branches
to
Line 360 if
X
equals 0. If not, BASIC
branches
to
Line 200
You can use GOTO in the command mode as an alternative
to
RUN.
This lets you
pass
values assigned
as
a command
to
vari-
ables used in the program.
Example
GOTO 100
BASIC transfers control
to
Line 100.
Sample
Program
10
20
30
40
50
60
70
80
Line 10
READ
R
IF
R
=
13 THEN 80
PR
I
NT
"R
="
;
R
A=3.1 4*RA2
PRINT "AREA
=";A
GOTO 10
DATA 5,7,12, 13
END
reads each
of
the data items in Line 70; Line 60 returns
program control
to
Line
10.
This enables
BASIC
to
calculate the
area for each of the data items until it reaches item
13.
173