EasyManua.ls Logo

Commodore 1581 - Using Relative Files: RECORD# Command

Commodore 1581
138 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...
BASIC
2.0:
200
INPUT'WHICH
FILE";FI$
210
OPEN
5,8,5,FI$
USING
RELATIVE
FILES:
RECORD#
COMMAND
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
two
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.
This
means
each
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.
FORMAT
FOR
THE
RECORD#
COMMAND:
BASIC
7.0:
RECORD
#
file
#,
record
number
[,offset]
BASIC
2.0:
PRINT#15,
"P"
+
CHR$
(channel
#
+
96)
+
CHR$
(<record
#)
+
CHR$(>record
#)
+
CHR$(offset)
where
"file
#"
is
the
file
#
specified
in
the
current
DOPEN
statement
for
the
specified
file,
"record
number"
is
the
desired
record
number,
"channel
#"
is
the
channel
number
specified
in
the
current
OPEN
statement
for
the
specified
file,
"<record
#"
is
the
low
byte
of
the
desired
record
number,
expressed
as
a
two-byte
integer,
">record
#"
is
the
high
byte
of
the
desired
record
number,
and
an
optional
"offset"
value,
if
present,
is
the
byte
within
the
record
at
which
a
following
Read
or
Write
should
begin.
To
fully
understand
this
command,
you
must
understand
how
most
integers
are
stored
in
computers
based
on
the
6502
and
related
microprocessors.
In
the
binary
arithmetic
used
by
the
microprocessor,
it
is
possible
to
express
any
unsigned
integer
from
0-255
in
a
single
56

Table of Contents

Other manuals for Commodore 1581

Related product manuals