Personal Computer News


16K Random Access Files

 
Published in Personal Computer News #095

16K Random Access Files

BBC owners can create random access files on disk using less than the 16K of disk space claimed by the OS.

The manuals mention that since any file can be accessed by the random access commands (OPENIN, OPENUP, PRINT#, etc), you can reserve disk space for files longer than 16K simply by using *SAVE "filename" SSSS +LLLL to save any block of code of the required length from anywhere in memory (i.e. any garbage at all). You can then write to and read from the file using OPENUP("filename") and OPENIN("filename")

You can use the same technique to create files on disk shorter than the default 16K.

X=OPENOUT("NAME"):CLOSE#X
This creates a file on the disk, while the operating system reserves the default 64 sectors, or 16K

*SAVE "NAME" 0000 +8000
This creates a file on the disk, 32K long, which can be accessed by OPENUP and OPENIN in the usual way.

*SAVE "NAME" 0000 +00FF
This creates a file on the disk only 255 bytes long, which can also be accessed in the usual way, by OPENUP and OPENIN. This is a very handy technique for storing small data files, without using large amounts of disk space.

Archibald McDonald
Glasgow

Archibald McDonald