User`s manual

BLOCK.ALLOCAIE
In order to safely use random files along with regular files, your programs
must check the BAM to find available blocks, and change the BAM to reflect
that you've used them. Once you update the BAM, your random tiles will be
safe-at least unless you perform the VALIDATE command (see chapter 3).
FORMAT FOR THE BLOCK-ALLOCATE COMMAND:
PRINT# file#, "BLOCK.ALLOCATE:" drive, track, block
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 attempt 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 then allocate that block.
EXAMPLE OF PROCEDURE TO ALLOCATE BLOCK:
10OPEN15.8,15
20 OPEN5,8,5, "# DRIVE
30PRINT#5,"DATA" / ~
40T=I:S=1 ~ ~
50 PRINT#15, "B-A:"0, T, S~
60 INPUT#15, A, B$, C, D
70 IF A=65 THEN T=C: S=D: GOTO 50
80 PRINT# 15, "B.W:" 5,0, T, S
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 casejust in the BAM.
FORMAT FOR BLOCK.FREE COMMAND:
PRINT# f1le#, "BLOCK-FREE:" drive, track, block
or abbreviated as
PRINT# file#, "B.F:" drive, track, block
Using Random Files
The only problem with what you've learned about random fIles so far is
29