tell/1

Synopsis

tell(+FileOrStream)

makes FileOrStream the current output stream.

Arguments


FileOrStream file_spec or stream_object
file specification or stream object.

Description

If there is an open output stream currently associated with the filename, and that stream was opened by tell/1, then it is made the current output stream;

Otherwise, the specified file is opened for output and made the current output stream. If the file does not exist, it is created. If it is not possible to open the file (because of protections, for example), tell/1 raises an exception.

Different file names (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 (ref-iou-sfh-cst) or close/1 (ref-iou-sfh-cst).

Exceptions


instantiation_error
FileOrStream is not instantiated enough.
domain_error
FileOrStream is neither a filename nor a stream.
permission_error
FileOrStream exists but cannot be opened.
existence_error
FileOrStream not currently open for input, and fileerrors flag is on.

See Also

told/0, telling/1