By default, a stream uses the platform file system's line delimiter
for operations such as cr and nextLine. A string
representing the current line delimiter can be obtained by sending the
lineDelimiter message to a file stream instance, and can be changed
to an arbitrary string by sending the lineDelimiter:
message. This makes it possible to adopt a single platform's file
convention as the standard for all platforms, or to use nextLine to
read files written on other platforms. The following table lists the
line delimiter constants defined in the CldtConstants pool
dictionary:
Table 9. Line Delimiter constants in the CldtConstants pool dictionary
The following example demonstrates the use of the lineDelimiter: message and line delimiter constants, as well as their effect on the cr message:
| file | file := CfsReadWriteFileStream openEmpty: 'testing.txt'. "Use OS/2 line delimiter" file lineDelimiter: PMLineDelimiter. file cr; nextPutAll: '<-os/2 line delimiter'.
"Set back to default line delimiter" file lineDelimiter: LineDelimiter. file cr; nextPutAll: '<-default line delimiter'.
"Use an arbitrary line delimiter" file lineDelimiter: '[end of line]'. file cr; nextPutAll: '<-arbitrary line delimiter'. file close.