[Coco] RS-DOS: EOF() but for writing?

Allen Huffman alsplace at pobox.com
Thu Jan 26 15:54:10 EST 2023


> On Jan 26, 2023, at 2:49 PM, Christopher R. Hawks via Coco <coco at maltedmedia.com> wrote:
> 
>    AFAIK, disk files are automagally extended until the disk is full.
> 
>    You could use FREE(0) , but that will only indicate free granules
> (2304 bytes each).


Ah, you could check that before, and then plan accordingly.

Does FREE(0) return a value back to BASIC?

(Runs to check XRoar)

10 X=FREE(0)
20 PRINT X

It does! Thanks, Chris. That tells me a way to do this in BASIC, but it would be up to the program to track how many bytes of data it is writing out in order to know when to stop.

0 ‘DF=DISK FREE
1 ‘DU=DISK USED
2 '
10 DF=FREE(0)*2304:DU=0
20 OPEN “O”,#1,”BIGFILE”
30 A$=“HERE IS SOME DATA TO ADD TO THE FILE”
40 IF DU<DF THEN GOSUB 1000:GOTO 30
50 CLOSE #1
999 END
1000 ‘ WRITE A$ TO DISK
1010 DU=DU+LEN(A$)
1020 IF DU<DF THEN PRINT #1,A$;
1030 RETURN

--
Allen Huffman - PO Box 7634 - Urbandale IA 50323 - 515-999-0227 (vmail/TXT only)
http://www.subethasoftware.com - https://www.facebook.com/subethasoftware




More information about the Coco mailing list