open/4 option: format(Format) QP_stream: unsigned char format
This field indicates the format of a stream. The format
tells the
middle layer functions how to wrap (unwrap) a record.
Possible formats are:
QP_VAR_LEN
format(variable)
in open/4
.
Each record in the file has its own length. The middle layer input
function trims the trailing blank characters in each record if trimming
is turned on for the stream.
The input/output system does not alter any character in each record
for a QP_VAR_LEN
format stream with no trimming and no line
border code.
QP_DELIM_LF
format(delimited(lf))
in open/4
.
From an application program's point of view, each record in the file is
terminated with a single <LFD>. Under Windows,
however, what's actually stored in the file is the sequence <RET><LFD>.
QP_DELIM_TTY
format(delimited(tty))
in open/4
.
The file stream is a terminal device or a terminal emulator.
What characters delimit each record depends on the host operating system.
The Prolog input/output system treats this format like QP_DELIM_LF
as far as record termination is concerned.
The Prolog input/output system also automatically provides special
services for streams with QP_DELIM_TTY
format
(see fli-ios-tty).
For a delimited record format stream, the middle layer input function removes the delimiting character at the end of each record and the line border code for the stream is returned to a top layer input predicate (function) when the end of a record is reached. The middle output layer output function adds the delimited character at the end of each record before the record is passed to the bottom layer write function.
The format
field may be set to QP_FMT_UNKNOWN
when
a stream structure is created if the format to be used is not known yet,
for example, because the underlying device is not yet opened.
This format field must be set to a proper format before any I/O takes place
on the stream.
An example of this is
when opening a Prolog stream through open/[3,4]
or QP_fopen()
without specifying the format.
The embedding open function, QU_open()
is given the stream format
QP_FMT_UNKNOWN
and thus chooses an
appropriate format for the stream based on the filename and options
of the stream.
Depending on the host operating system, some formats may be
used more frequently than others.
QP_DELIM_LF
and QP_DELIM_TTY
are the most frequently used
formats for a Prolog system running under UNIX or Windows.
QP_VAR_LEN
is more frequently used under VMS.