RUN
it a few
times to feel
comfortable
with it and be
sure
it is "debugged".
Anyway, this
program works fine for
examining the value
of a variable,
N,
and sending the
Computer off to
a certain line number to do
what
it
says
there. If
there
are lots of possible
directions in
which to branch, however, we will want to
use
a
greatly improved
test called
ON-GOTO
which cuts
out lots of
lines of programming.
Let's
examine
an
ON-GOTO after
you do
the following:
Erase
lines
20, 30,
40,
50
and
60
Enter this new line:
20 ON N GOTO
110,130,150,170,190
. .
,
and RUN
the
program a few times, as before.
Works
just the same,
doesn't it?
The ON-GOTO
statement
is
really pretty
simple, though it looks hard.
Line
20
says,
if the INTEGER
value
of
N is 1 then GOTO
line
110.
if the
INTEGER value of N
is
2
then GOTO line
130.
if the
INTEGER
value of N is 3
then GOTO
line
150.
if the INTEGER
value of N is 4 then GOTO
line
170.
if the INTEGER
value of
N is
5
then GOTO
line
190.
if
the
INTEGER value of N is
not one of the
numbers listed above, then move
on
to
the next line.
The ON-GOTO statement has its own
built-in INT statement. It really acts like this:
20
ON
INT(N)
GOTO
.
.
. ETC.
Type
in
the
following values of N to
prove
the point:
1 .5
3. 99999
. 999
5 .999
6 0001
Get the picture?
78
Debugged
is
an
old
l&tSft
w0ttT*hi6a, freely
translated,
means
"getting
all
the swots out
of
your
your
Computer
program."
.
Remember, an
integer
is just a whole number.