[Coco] Updating RSDOS text files with DISK BASIC ver, 2,1

William Astle lost at l-w.ca
Mon Dec 19 15:04:56 EST 2022


On 2022-12-19 10:42, coco at jechar.ca wrote:
> I am not sure I understand how you would keep the two
> files in sync without random access ? Unless you are
> essentially talking about using FILE.TXT and FILE.NEW where
> FILE.NEW starts out empty and gets it's input from FILE.TXT after
> FILE.TXT has been processed. Them manually from the OS after one
> could delete FILE.TXT copy FILE.NEW to FILE.TXT and then delete FILE.NEW
> 
> I assume that the command
> 
> OPEN "I", #4,"FILE.NEW" creates a new empty text file named FILE.NEW ?

No, that will cause an NE error if the file doesn't exist or open the 
file for input. You want "O" for the mode in which case it will create 
an empty file if it doesn't exist. It may create an AE error if the file 
does exist, though.

You would be opening FILE.TXT and FILE.NEW *at the same time*. Then you 
would read some stuff from FILE.TXT, do whatever you're going to do to 
the data, and write to FILE.NEW immediately. FILE.TXT would be opened in 
"I" mode and FILE.NEW in "O" mode.

I was assuming your data was freeform (text or whatever) in which case 
the above is the only reasonable way to modify the file contents.

If it is fixed format record data, then there is a random access mode 
("R" or "D") which allows modifying the contents of the file in place. 
There's a bit more to it than just READ/INPUT and PRINT, though, and 
it's been too long since I messed with that stuff to give you detailed 
pointers.



More information about the Coco mailing list