Commodore Computer Commodore 64 Uživatelský manuál Strana 32

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 65
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 31
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, sinceit 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
UsingRandom Files
The only problem with what you've learned about random fIles so far is
29
Zobrazit stránku 31
1 2 ... 27 28 29 30 31 32 33 34 35 36 37 ... 64 65

Komentáře k této Příručce

Žádné komentáře