Next: , Previous: , Up: mpg-bpr   [Contents][Index]


11.3.224 tell/1

Synopsis

tell(+FileOrStream)

Makes file FileOrStream the current output stream.

Arguments

FileOrStream

file_spec or stream_object, must be ground

Description

If there is an open output stream associated with FileOrStream, and that stream was opened by tell/1, then it is made the current output stream. Otherwise, the specified file is opened for output in text mode with default options and made the current output stream.

Different file names (that is, names that do not unify) represent different streams (even if they correspond to the same file). Therefore, assuming food and ./food represent the same file, the following sequence will open two streams, both connected to the same file.

tell(food)
…
tell('./food')

It is important to remember to close streams when you have finished with them. Use told/0 or close/[1,2].

Exceptions

instantiation_error

FileOrStream is not instantiated enough.

existence_error

FileOrStream specifies a nonexisting file, and the fileerrors Prolog flag is on.

permission_error

FileOrStream is a stream not currently open for output, or FileOrStream specifies a file with insufficient access permission, and the fileerrors Prolog flag is on.

domain_error

FileOrStream is neither a file_spec nor a stream_object.

See Also

told/0, open/[3,4], current_output/1, ref-iou-sfh, ref-lps-flg.


Send feedback on this subject.