Chapter 8 Peripheral Devices 275
Suppose you wanted to read the
data
in a specific 240-byte file as
separate records. The first record resides in bytes 1 through
120
and the
other
is
stored in bytes
121
through 240. Reading the files in order would be
easy because the
BUFFER-POINTER
would already be
at
the point where
the second file starts after reading the first file. But what if you only wanted
to read the second
file?
One way to read the second file would be to perform
120
GET#
instructions, using a short loop, until you got to byte
121.
This can be accomplished more easily, however. The
BUFFER-
POINTER
instruction will allow you to point
at
any byte in the buffer. Its
format
is
PRINT#15, "B-P:" sa;byte
where:
PRINT#15, activates the command channel
"B-P:"
is
the BUFFER-POINTER command
sa;
is
the secondary address
byte
is
the byte you want to access.
For
example, if you wanted
to
GET the 120th byte
of
a block, you
would use
PRINTi15J
"B-P:"4;15
BLOCK-FREE
The BLOCK-FREE instruction will deallocate any block on the
diskette. This instruction tells the BAM to mark the block specified as
available, thus allowing
data
to
be written to the block.
To perform a BLOCK-FREE, use the following format:
OPEN 15,8,15
PRINT#15, "B-F:"
dr;trk;sec
where:
PRINT#15, activates the command channel
"B-F:"
is
the BLOCK-FREE command
dr
is
the drive number
trk
is
the track number
sec
is
the sector number.