Quantcast
Channel: stardot.org.uk
Viewing all articles
Browse latest Browse all 2385

programming • Re: Random access files: Avoiding 'can't extend'

$
0
0
From playing with OPENOUT (and *BUILD too) it seems that DFS needs to find a 16K block of storage on the disc surface even if the file to be created is very small.

On a Master use *CREATE to reserve a block of memory large enough for your file.

On a BBC micro use *SAVE similarly.

OPENOUT will overwrite the exiting file in the space reserved.

To check if the file exists make sure that the first byte in the 'empty' file is a known value, say 99. Use OPENIN and BGET# to read the first byte. If the first byte is not 99 then OPENOUT will create the file for you overwriting the existing. If the first byte is 99 then use OPENUP to append data. You will not be able to append data beyond the length of the reserved storage.

That description is not strictly random access filing. An easy way to do that is to have fixed length records then use OPENUP and PTR# to position the file write pointer and then save the data with BPUT#.

It is tricky but quite fun when it works.

Statistics: Posted by flaxcottage — Sun Dec 31, 2023 9:03 pm



Viewing all articles
Browse latest Browse all 2385

Trending Articles