seeing(?name)

This built-in predicate identifies the name of the current input stream. The name of the current input stream is unified with the value of the parameter Name. If the current input stream is connected to a file then the name of the file is returned, if the standard input stream is the current input stream then the value 'user' is unified with the Name parameter.

Arrow.gif (1632 bytes)To preverse compatibility with other Prolog systems not the name 'user_input' is returned, but 'user'. This predicate is not defined in the ISO Prolog standard.

see also: at_end_of_stream/0 at_end_of_stream/1 close/1 close/2 close_user_streams/0 current_input/1 current_output/1 flush_output/0 flush_output/1 open/3 open/4 prolog I/O set_input/1 set_output/1 set_stream_position/2 stream_property/2

Example
seeing(Name). Name is unified with the term 'user', which is the name of the standard input stream
see('c:\\temp\\test.txt'),
seeing(Name),
seen.
the file 'c:\\temp\\test.txt' is opened and made the current input stream (if the file exists) then seeing/1 is used to retrieve the name of the current input stream, the value of Name after seeing/1 is 'c:\\temp\\test.txt',  the stream is then closed.

 

 

info@trinc-prolog.com