EasyManua.ls Logo

Commodore 1541 - Using Random Files

Commodore 1541
80 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...
How
do
you
know
which
blocks
are
available
to
use?
If
you
try
a
block
that
isn't
available,
the
DOS
will
set
the
error
message
to
number
65,
NO
BLOCK,
and
set
the
track
and
block
numbers
to
the
next
available
track
and
block
number.
Therefore,
any
time
you
atlempl
to
write
a block
to
the
disk,
you
must
first
try
to
allocate
that
block.
If
that
block
isn't
available,
read
the
next
block
available
from
the
error
channel
and
[hen
allocate
that
block.
EXAMPLE
OF
PROCEDURE
TO
ALLOCATE
BLOCK:
10
OPEN15TS.15
30
PRINTS,"DATA"
40
T=1:B=1
SO
PRINTtfl5P"B-A:"(fcT:B
60
INPUTtflS.A.BS^.D
70 IF
A-65
THEN
T=
C:B
=
D:GOTO50
80
PRINT
tfl5,"B-W:"5;QJ;l
90
CLOSE5:CLOSEI5
BLOCK-FREE
The
BLOCK-FREE
command
is
the
opposite
of
BLOCK-ALLOCATE,
in
that
it
frees
a block
that
you
don't
want
to
use
anymore
for
use
by
the
system.
It
is
vaguely
similar
to
the
SCRATCH
command
for
files,
since
it
doesn't
really
erase
any
data
from
the
disk
just
frees
the
entry,
in
this
case
just
in
the
BAM.
FORMAT
FOR
BLOCK-FREE
COMMAND;
PRlNT#file0,
"BLOCK-FREE:"
drive;
track;
block
or
abbreviated
as
,
"B-F:"
drive;
track;
block
USING
RANDOM
FILES
The
only
problem
with
what
yc-u've
learned
about
random
files
so
far
is
that
you
have
no
way
of
keeping
track
of
which
blocks
on
the
disk
you
used,
After
all,
you
can't
tell
one
used
block
on
the
BAM
from
another.
You
can't
tell
whether
it
contains
your
random
file,
just
part
of
a
program,
or
even
sequential
or
relative
files.
To
keep
track,
the
most
common
method
is
to
build
up
a
sequential
file
to
go
with
each
random
file.
Use
this
file
to
keep
just
a
list
of
record,
track,
and
block
locations.
This
means
that
there
are
I
channels
open
ro
the
disk
for
each
random
file:
one
for
the
command
channel,
one
for
the
random
data,
and
the
other
for
the
sequential
data.
This
also
means
that
there
arc 2
buffers
that
you're
filling
up
at
ihe
same
time!
3J

Other manuals for Commodore 1541

Related product manuals