In this example, if X is less than 0, the 26 IF X<0 THEN PRINT
PRINT statement will be executed and "ERROR, X NEGATIVE":
then the GOTO statement will branch to GOTO 350
line 350. If the X was 0 or positive,
BASIC will proceed to execute the lines
after line 26.
STATEMENT SYNTAX/FUNCTION EXAMPLE
LET [LET] variable = expression 300 LET W=X
Assigns a value to a variable,
"LET" is optional. 310 V=5.1
STATEMENT SYNTAX/FUNCTION EXAMPLE
NEXT NEXT [variable] [,variable] ... 340 NEXT V
Marks the end of a FOR loop.
If no variable is given, matches the most 345 NEXT
recent FOR loop,
A single NEXT may be used to match 350 NEXT V,W
multiple FOR statements. Equivalent
to NEXT V:NEXT W.
STATEMENT SYNTAX/FUNCTION EXAMPLE
ON...GOSUB ON expression GOSUB line [,line] ... 110 ON I GOSUB 50,60
Identical to "ON...GOTO," except that
a subroutine call (GOSUB) is executed
instead of a GOTO. RETURN from the
GOSUB branches to the statement after
the ON...GOSUB.
STATEMENT SYNTAX/FUNCTION EXAMPLE
ON...GOTO ON expression GOTO line [, line] ... 100 ON I GOTO 10,20,
Branches to the line indicated by the 30,40
I'th number after the GOTO. That is:
IF I=1, THEN GOTO LINE 10
IF I=2, THEN GOTO LINE 20
IF I=3, THEN GOTO LINE 30
IF I=4, THEN GOTO LINE 40.
If I=0, or I attempts to select a nonexistent
line (>=5 in this case), the statement after
the ON statement is executed. However, if
I is >255 or <0, an FC error message will
result. As many line numbers as will fit on
a line can follow an ON...GOTO.
This statement will branch to line 40 if the 105 ON SGN(X)+2
expression X is less than zero, to line 50 if GOTO 40,50,60
it equals zero, and to line 60 if it is greater
than zero.
STATEMENT SYNTAX/FUNCTION EXAMPLE
REM REM any text 500 REM NOW SET
Allows the programmer to put comments V=0
in his program. REM statements are not
executed, but can be branched to. A REM
statement is terminated by end of line, but
not by a ":".
In this case the V=0 will never be executed 505 REM SET V=0:
by BASIC. V=0