__FILE__

If the compiler encounters a variable with the name __FILE__ in the source then it replaces that variable with the name of the file being compiled at that moment. This can be useful for debugging Prolog programs as __FILE__ can be used by debug predicates that write and/or log messages of a Prolog application.

see also: __HOST__ __LINE__ __MODULE__

Examples
start( __FILE__ ). If the predicate start/1 is located in the file 'c:\\temp\\test.txt' and the goal 'start(X).' is proven then the variable X be unified with the name of the file.
X = 'c:\\temp\\test.txt'

 

 

info@trinc-prolog.com