bwbasic does not handle binary files correctly
In GW-BASIC and QBasic, if you open a file with
OPEN f$ FOR RANDOM AS #1 LEN=1
it treats the file as binary, which means that '\0' characters are allowed, and '\n' does not get translated to '\r\n'.
bwbasic, on the other hand, does not handle binary files at all, and if you try to do something like
10 f$ = "test.bin"
20 OPEN f$ FOR RANDOM AS #1 LEN=1
30 FIELD #1, 1 AS s$
40 LSET s$=CHR$(0)
50 PUT #1
60 LSET s$=CHR$(&h0A)
70 PUT #1
80 CLOSE #1
in both GW-BASIC and QBasic the resulting file is a 2-byte file with the values 0x00 and 0x0A. In bwbasic, the resulting file is a 3-byte file with the values 0x00, 0x0D and 0x0A, because bwbasic does not handle binary files.
Attached is a patch for bwbasic to correctly handle this situation: bwbasic.patch
Given that bwbasic development is a bit hard to track (sourceforge has releases, but I don't see anything for contributing; there's a GitHub page https://github.com/nerun/bwbasic that is archived, and the GitHub page links to https://yeolpishack.net/repos/ChipMaster/bwBASIC , however I don't have a clue on how to contribute there), I decided to post the fix here, hoping that the next FreeDOS version will have my patch included.