Commodore 16 User Manual
Download Operation & user’s manual of Commodore 16 Desktop for Free or View it Online on All-Guides.com.
The NEXT slalemeni
Is
used
with ihe FOR statement. When
the
computer encouniers
a
NEXT statement,
it
goes back to the
corresponding FOR statement
and checks
the
loop variable
(See
FOR
statement tor
more detail.) It the loop is finished, execution proceeds
with the statement
after the NEXT statement. The word NEXT may be
followed
by a
variable name,
a
list ot
variable
names separated by
commas, or no
variable
names. It there are no names
listed, the last
loop started is me
one being
completed
H the variables are given, they
are
completed
In
order trom left
to
right
EXAMPLE:
10 FOR L
«
20 FOH L
<
30
FOR L
1 TO 10:NEXT
1 TO 10:NEXT L
1 TO 10:FOR M
=
1 TO 10:
NEXT
M, L
ON
ON
expression
<GOTO/GOSUB>
line #1
[.
line
#2,
This command can make the
GOTO
and
GOSUB
statements mlo
special versions ol
the IF
statement The word ON is followed
by a
formula, then either GOTO or
GOSUB.
and a list ol
line
numbers
separatee by commas. If the
result
ol the
calculation
of the
formula
(expression)
ts
1
. the
first line
in the
list
is executed.
II
Ihe
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 next
line
executed
is tne statement following
the ON statements
II
Ihe
number is negative,
an ILLEGAL
QUANTITY
ERROR results
l
;
f
.
I
f
f
!
I
I
I
I
I
I
I
I
(
I
r
f
^26
i
r
EXAMPLE:
10 INPUT
X:IF X<0 THEN 10
20 ON X
GOTO 50, 30, 30, 70
25 PRINT "FELL THROUGH":GOTO
10
30 PRINT "TOO HIGH":GOTO
10
50 PRINT'TOO
LOW'rGOTO
10
70
END
When
X
=
1
. ON
sends control
to the
lirsl line
number in
the
lisl
(50) When X
-
2.
ON sends control
to
the second line
(30),
etc.
OPEN
OPEN
Me
[.device
# (.secondary address
f.
"filename, type,
mode"]|l
The OPEN statement allows your Commodore 16
lo access
devices
such as the
Datassette
recorder
and disk for data, a primer or even the
monitor screen
The
word
OPEN is followed
by a
logical file
number,
which is the
number to which all other BASIC
statements
will
refer This
number is from 1
to
255. There is normally
a second number after
the
first called
Ihe device number Device number is
the Commodore 16
keyboard.
3 is Ihe
screen,
1 is the Datassette recorder
(default), 4 is the
printer.
8
is usually the
disk. A
*ero
(0) may be included in tront of
the
device number
digit
(e
g
,
08 to*
8. which are
interchangeable
as far as
your Commodore 1
6
is
concerned). It
Is
often
a good Idea lo use the
same file number
as the
device
number because it makes it
easy to
remember
which Is which. Following the
second number may
be a
third
number called the
secondary address. In the
case ol
tne
cassette,
this
can be fo' read. 1 lor write,
ana 2 lor write with end-of-lape
marker
at Ihe end.
In
the
case of the disk, Ihe number refers to the
channel number. In
the printer, the
secondary addresses are used to
set Ihe mode of the printer
See the
Commodore
1 6 Programmer's
Reference Manual
or the manual lor each
specific
device
for more
information
on secondary addresses There
may
also
be a
string
following
the third number,
which
could
be
a
command
to
the disk
drive or the name
ol the file
on tape or disk. The type and mode refer
127