Next, On number gosub, On number goto – Xylem System 5000 BASIC Manual User Manual
Page 37

35
Basic Commands and Functions
Declares the end of a FOR loop. The initial FOR variable may be optionally specified.
FOR a = 1 TO 10 STEP 2
PRINT “ “, a; REM prints “ 1 3 5 7 9”
NEXT a
NEXT
Negates the expression immediately following. The ! operator may alternatively be used.
FOR a = 1 TO 10 STEP 2
IF (NOT a > 5)
REM NOT effectively changes our expression to (a <= 5)
PRINT “ “, a;
REM prints “ 1 3 5”
NEXT a
NOT
Branches to one of a list of GOSUBs based on the given number/argument. For example, if the
given number is 1, the first GOSUB listed is used, if the number is 2, the second GOSUB, etc.
FOR a = 1 TO 3
ON a GOSUB print1, print2, print3
NEXT a
END REM the final printout is: “ 1 (2) *3*”
LABEL print1
PRINT “ “, a;
RETURN
LABEL print2
PRINT “ (“, a;
PRINT “)”;
RETURN
LABEL print3
PRINT “ *”, a;
PRINT “*”;
RETURN
ON number GOSUB
Jumps to one of a list of GOTOs based on the given number/argument. For example, if the given
number is 1, the first GOTO listed is used, if the number is 2, the second GOTO, etc. Unlike GOSUB,
GOTO statements never return back to the point of the GOTO.
FOR a = 1 TO 3
ON a GOTO print1, print2, print3
NEXT a
END REM the final printout is: “ 1” as the other Labels are not reached
ON number GOTO