The predicates below are part of the Quintus compatible stream-based I/O package. In this package streams are explicitly created using the predicate open3. The resulting stream identifier is then passed as a parameter to the reading and writing predicates to specify the source or destination of the data.
aliasAtom Gives the stream a name. Below is an example. Be careful with this option as stream-names are global. See also set_stream2.
eof_actionAction Defines what happens if the end of the input stream is reached. Action eof_code makes get01 and friends return -1 and read1 and friends return the atom end_of_file. Repetitive reading keeps yielding the same result. Action error is like eof_code, but repetitive reading will raise an error. With action reset, Prolog will examine the file again and return more data if the file has grown.
bufferBuffering Defines output buffering. The atom fullf (default) defines full buffering, line buffering by line, and false implies the stream is fully unbuffered. Smaller buffering is useful if another process or the user is waiting for the output as it is being produced. See also flush_output[0,1]. This option is not an ISO option.
close_on_abortBool If true (default), the stream is closed on an abort (see abort0). If false, the stream is not closed. If it is an output stream, it will be flushed however. Useful for logfiles and if the stream is associated to a process (using the pipe1 construct).
The option reposition is not supported in SWI-Prolog. All streams connected to a file may be repositioned.
open3+SrcDest, +Mode, ?Stream Equivalent to open4 with an empty option-list.
open_null_stream1?Stream Open a stream that produces no output. All counting functions are enabled on such a stream. An attempt to read from a null-stream will immediately signal end-of-file. Similar to Unix /dev/null. Stream can be an atom, giving the null-stream an alias name.
close1+Stream Close the specified stream. If Stream is not open an error message is displayed. If the closed stream is the current input or output stream the terminal is made the current input or output.
close2+Stream, +Options Provides closeStream, [force(true)] as the only option. Called this way, any resource error (such as write-errors while flushing the output buffer) are ignored.
stream_property2?Stream, ?StreamProperty ISO compatible predicate for querying status of open I/O streams. StreamProperty is one of:
If the seek modifies the current location, the line number and character position in the line are set to 0.
If the stream cannot be repostioned, a reposition error is raised. The predicate seek4 is compatible to Quintus Prolog, though the error conditions and signalling is ISO compliant. See also stream_position3. set_stream2+Stream, +Attribute Modify an attribute of an existing stream. Attribute is in the current implemention only aliasAliasName to set the alias of an already created stream. If AliasName is the name of one of the standard streams is used, this stream is rebound. Thus, set_stream(S, current_input) is the same as set_input1 and by setting the alias of a stream to user_input, etc. all user terminal input is read from this stream. See also interactor0.