Commodore 128 System Manual page 291

Table of Contents

Advertisement

This statement can make the GOTO and GOSUB statements
operate like special versions of the (conditional) IF statement.
The word ON is followed by an expression, then either of the
keywords GOTO or GOSUB and a list of line numbers separated
by commas. If the result of the expression is 1, the first line in the
list is executed. If the result is 2, the second line number is
executed and so on. If the result is 0, or larger than the number of
line numbers in the list, the program resumes with the statement
immediately following the ON statement. If the number is
negative, an ILLEGAL QUANTITY ERROR results.
EXAMPLE:
10 INPUT X:IF X <0 THEN 10
20 ON X GOSUB 30, 40, 50, 60
25 GOTO 10
30 PRINT "X = 1''¡RETURN
40 PRINT "X = 2":RETURN
50 PRINT "X = 3":RETURN
60 PRINT "X = 4":RETURN
When X = 1 , ON sends control to the first line number in the list
(30). When X=2, ON sends control to the second line (40),etc.
OPEN
Open files for input or output
OPEN logical file number, device number [,secondary address]
[< ,"filename, filetype, mode" | ,cmd string>]
The OPEN statement allows the Commodore 128 to access files
within devices such as a disk drive, a Datassette cassette
recorder, a printer or even the screen of the Commodore 128.
The word OPEN is followed by a logical file number, which is the
number to which all other BASIC input/output statements will
refer, such as PRINT#(write), INPUT#(read), etc. This number is
from 1 to 255.
The second number, called the device number follows the logical
file number. Device number 0 is the Commodore 128 keyboard; 1
is the cassette recorder; 3 is the Commodore 128 screen, 4-7 are
normally the printer(s); and 8-11 are reserved for disk drives. It is
often a good idea to use the same file number as the device
number because it makes it easy to remember which is which.
17-49

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

128d

Table of Contents