EasyManua.ls Logo

Commodore Plus 4 - Page 341

Commodore Plus 4
464 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
The
Disk
Drive
329
OPEN
fUenumber,device,channel,
"fUename,L;'+CKR$Qengt2i)
where
filenumber
is
the
logical
file
number
(0-127),
device
is
the
disk
drive's
device
number,
channel
is
the
channel
to
use
(2-14),
and
filename
is
the
name
by
which
the
file
is
known.
The
record
length
is
a
number
(1-255) or
numeric
expression.
The
file
type
and
record
length
may
be
omitted
when
you
are
opening
an
existing
relative
file.
To
communicate
with
a
relative
file,
you
must
open
the
command
channel
of
the
disk
drive.
The
following
command
does
that:
OPEN
filenumber,device,l
5
where
filenumber
is
the
logical
file
number
(0-127,
but not
the
same
as
the
relative
file
itself),
and
device
is
the
drive's
device
number.
To
read
or
write
a
record
in
the
relative
file,
the
file
pointer
must
be
positioned
to
the
desired
record
with
the
following
command:
PRINT#fiienumber//P//CHR$(ciinl)CHR$(rcio)CHR$(rcJ2i)
CHRl(pos)
where
filenumber
is
the
logical
file
number
assigned
to
the
command
channel,
chnl
is
the
channel
number
assigned
to
the
relative
file
in
its
OPEN
command,
rclo
is
the
low
byte
of
the desired
record
number,
rchi
is
the
high
byte
of
the
desired
record
number,
and
pos
is
the
position
in
the
record.
Errors
should
be
caught
after
this
statement
by
examining
DS
and
DS$.
If
the
record
requested
does
not
exist,
DS
returns
a
50.
It
should
be
noted,
however,
that
whenever
a
new
sector
on
the
disk
is
added
to
the
file,
every
record
that
it
would
contain
exists,
even
if
that
record
has
not
been
written
to.
The
first
byte
of
a record
that
has not
been
written
to
is
always
a
CHR$(255).
This
example
program
sets
up
a
relative
file
containing
names
and
phone
numbers.
The
record
size
is
21
(10
for
the
name,
then
a
separating
comma,
and
10
for
the
phone
number).
Each
time
the
program
is
run, the
user
may
add
a
name
and
number
or
retrieve
a
name
and
number.
Example:
10
OPEN1,8,2/'PHONES,L,"+CHR$(21)
20
IFDSO0THENPRINTDS$:CLOSE1:END
30
OPEN15,8,15
40
IFDS<>0TOENPRINTDS$:GOTO170
50
PRINTMDO
YOU
WANT
TO
ADD
A
NAME";:INPUTA$
60
IFLEFT$(A$,1)="Y"THEN180
70
PRINT"WHOSE
NUMBER
DO
YOU
NEED";:INPUTN$
80
N$=LEFT#(N$,10)
90
R=l
100
PRINT#15f"P"CHR$(2)CHR$(RAND255)CHR$(INT(R/256))CHR$(l)
110
IFDSO0THENPRINTDS$:GOTO170