Tech Tip: Differences in break modes when creating file handles
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: February 13, 2023
When creating FileHandle objects, the File.open() function can take in an options object with properties that customize the file handling process (see below).
Options object
var $o : Object $o:=New object() $o.mode:="read" $o.charset:="UTF-8" $o.breakModeRead:=Document with CRLF $o.breakModeWrite:=Document with CRLF $fileHandle:=$file.open($o) |
The mode and charset properties are fairly straightforward, but it can be confusing to understand what is meant by the breakModeRead and breakModeWrite properties. Essentially, they determine the end-of-line characters being used in the file. The end-of-line character(s) used when processing the file will depend on the operating system (refer to the table below).
Table of 3 break modes

Example in MacOS:

Since 4D databases are often programmed for both Windows and Mac platforms, it can be a hassle to design your code to accommodate for both environments; luckily, you may use the Document with native format constant that will automatically detect which platform 4D is being run in and apply its corresponding end-of-line character(s).
Native break mode
$o.breakModeRead:=Document with native format |