<<Cheats >>

Home Page

Projects...
PC Controller Box
Joystick Switch Box
c128D Refurb

Programs...
Byte Simulator
Cheat 'O Matic
GEOS

Collections...
3D Models
Book Collection

Information...
My BASIC Notes
Web Links

eMail Me

Note: You must add uk to the end of the address, it's to help prevent spam.

My BASIC Notes

Basic2 Commands
Disk Drives
ASCII and CHR$ Codes
PEEK's and POKE's
RAM Memory Map
ROM Memory Map
Screen Display
Sprite

ON
Abbreviation:

TYPE: Statement
FORMAT: ON <variable> GOTO / GOSUB <line-number>[,<line-number>]...

Action: The ON statement is used to GOTO one of several given line-numbers, depending upon the value of a variable. The value of the variables can range from zero through the number of lines given. if the value is a non-integer, the fractional portion is left off. For example, if the variable value is 3, ON will GOTO the third line-number in the list.

If the value of the variable is negative, the BASIC error message ?ILLEGAL QUANTITY occurs. If the number is zero, or greater than the number of items in the list, the program just "ignores" the statement and continues with the statement following the ON statement.

ON is really an underused variant of the IF...THEN...statement. Instead of using a whole lot of IF statements each of which sends the program to 1 specific line, 1 ON statement can replace a list of IF statements. When you look at the first example you should notice that the 1 ON statement replaces 4 IF...THEN... statements.

EXAMPLES of ON Statement:

ON -(A=7)-2*(A=3)-3*(A<3)-4*(A>7)GOTO 400,900,1000,100
ON X GOTO 100,130,180,220
ON X+3 GOSUB 9000,20,9000
100 ON NUM GOTO 150,300,320,390
500 ON SUM/2 + 1 GOSUB 50,80,20


Commodore Cheetah made by Allen Monks, started in the year 2000.