.DO files are not binary files and are slightly limited in the characters they can contain. If you want to represent binary data in a DO file you need to encode it in some way, like HEX or custom. Custom formats can be more compact than HEX.
There is no limitation on the characters a binary file contains. But, binary files are harder to use, since you cannot open them directly, you can only load them back into RAM at their reserved load location... which itself creates a second copy of the data doubling RAM requirements. Alternatively if you have a CO in the RAM file system you could access the directory entry and peek the contents directly. This skips a decode operation. If you want to create a binary file, you need to create a CO file by saving a range of memory to a CO file. To create the initial contents you would POKE your bytes into a reserved region of memory. Another topic is embedding binary data into a tokenized BASIC program, for example in strings, in REM statement and in high-numbered unlistable lines of tokenized BASIC. That's also tricky but can result in machine code that can be run directly. You actually have to specially craft your ML code to do this. -- John. On Mon, Aug 15, 2022 at 1:49 AM B 9 <hacke...@gmail.com> wrote: > I was attempting to write a binary data file using BASIC's OPEN and PRINT > # commands and found that there are three bytes that are not allowed: 0, > 26, and 127. I had expected CHR$(26) might be a problem as that is the > End Of File character, but the other two were a surprise. Is this > limitation documented somewhere? It's not in the BASIC manual from Radio > Shack. > > Here's an example of what doesn't work: > > 10 open "foo.do" for output as #1 > 20 for t=0 to 255 > 30 print #1, chr$(t); > 40 next t > 50 close #1 > 80 open "foo.do" for input as #1 > 90 x=0 > 100 if eof(1) then 200 > 110 c = asc(input$(1,1)) > 120 if c<>x then print x > 130 x=c+1 > 140 goto 100 h > 200 close #1 > 210 end > > I can think of various workarounds, but they are ugly. What is the best > way to write binary files with arbitrary data from BASIC on a Model T? > > Thanks for any guidance. > > —b9 >