EasyManua.ls Logo

Commodore 1541-II - Using Relative Files: Record

Commodore 1541-II
104 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...
Notes:
1.
Do
not
precede
the
drive
number
with
the
"at"
sign
(@);
there
is
no
reason
to
replace
a
relative
file.
2.
,L
,"
+
CHR$(record
length)
is
only
required
when
a
relative
file
is
first
created,
though
it
may
used
later,
so
long
as
the
"record
length"
is
the
same
as
when
the
file
was
first
created.
Since
relative
files
may
be
read
from
or
written
to
alternately
and
with
equal
ease, there
is
no
need
to
specify
Read
or
Write
mode
when
opening
a
relative
file.
3.
"file
#",
"device
#"
and
"channel
#"
must
be
valid
numeric
constants,
variables
or
expressions.
The
rest
of
the
command
must
be
a
valid
string
literal,
variable
or
expression.
4.
Only
1
relative
file
can
be
open
at
a
time
on
the
1541,
although
a
sequential
file
and
the
command
channel
may
also
be
open
at
the
same
time.
EXAMPLES:
To
create
or
re-open
a
relative
file
named
"GRADES",
of
record
length
100,
use
OPEN
2,8,2,"GRADES,L,"
+CHR$(100)
To
re-open
an
unknown
relative
file
of
the
user's
choice
that
has
already
been
created,
we
could
use
200
INPUT"WHICH
FILE";FI$
210
OPEN
5,8,5,FI$
USING
RELATIVE
FILES:
RECORD#
When
a
relative
file
is
opened
for
the
first
time,
it
is
not
quite
ready
for
use.
Both
to
save
time
when
using
the
file
later,
and
to
assure
that
the
file
will
work
reliably,
it
is
necessary
to
create
several
records
before
closing
the
file
for the
first
time.
At
a
minimum,
enough
records
to
fill
more
than
2
disk
sectors
(512
bytes)
should
be
written.
In
practice,
most
programs
go
ahead
and
create
as
many
records
as
the
program
is
eventually
expected
to
use.
That
approach
has
the
additional
benefit
of
avoiding
such
problems
as
running
out
of
room
on
the
diskette
before
the
entire
file
is
completed.
If
you
simply
begin
writing
data
to
a
just-opened
relative
file,
it
will
act
much
like
a
sequential
file,
putting
the
data
elements
written
by
the
first
Print#
statement
in
Record
#1,
those
written
by
the
second
Print#
statement
in
record
#2
and
so
on.
(As
this
implies,
each
relative
record
must
be
written
by
a
single
Print#
statement,
using
embed
ded
carriage
returns
within
the
data
to
separate
fields
that
will
be
read
in
via
one
or
more
Input#
statements
later.)
However,
it
is
far
better to
explicitly
specify
which
record
number
is
desired
via
a
Record#
command
to
the
disk.
This
allows
you
to
access
records
in
any
desired
order,
hopping
anywhere
in
a
file
with
equal
ease.
Properly
used,
it
also
avoids
a
subtle
error
(bug)
common
to
all
Commodore
disk
drives.
57

Table of Contents

Related product manuals