P. 14
The conditional branching we tried above (IF .... THEN) can be
used for other purposes too. We can use a statement GOTO, telling
the Computer to go to a specific line number and continue from
there. Or, we can tell the Computer to go to a sub-routine
program (ON
... GOSUB 32000). Branching becomes a very powerful
tool in the hands of an experienced programmer (hang in there,
you'll become one).
Counting and Looping
Try this.
10 A = 0
20 A = A + 1
30 PRINT A
40 GOTO 20
RUN it and see what happens.
To stop the Computer, hit BREAK. To restart it, type CONT (for
CONTinue) . Hit CLEAR and see vjhat happens.
Now change line 30 to end with a comma. RUN it. Then try a semi-colon.
RUN it.
Add a line for branching.
35 IF A = 100 GOTO 100
100 END
RUN it. Or, you could combine lines 35 and 100 as follows:
35 IF A = 100 END