( fam1 -- fam2 )

Modify the implementation-defined file access method fam1 to additionally select a "binary", i.e., not line oriented, file access method, giving access method fam2.



Some operating systems require that files be opened in a different mode to access their contents as an unstructured stream of binary data rather than as a sequence of lines.

The arguments to READ-FILE and WRITE-FILE are arrays of character storage elements, each element consisting of at least 8 bits. The committee intends that, in BIN mode, the contents of these storage elements can be written to a file and later read back without alteration.


AntonErtlavatar of AntonErtl [31] Text mode is a bad idea for file openingComment2017-08-15 16:54:05

BIN has led us astray at first in Gforth: We thought that the idea was to use BIN like the "b" modes in C's fopen, (and, more importantly, no "b" without BIN) but this led to problems in connection with FILE-POSITION, REPOSITION-FILE, and RESIZE-FILE. And because READ-LINE and WRITE-LINE can make the program completely agnostic about the line terminator, our eventual conclusion was that we open all files in binary code, and deal with CRLF in our implementation of READ-LINE and WRITE-LINE instead of letting the C library translate it into an LF. This has been in use for about 20 years with no complaints.

Reply New Version