SWI-Prolog -- prolog_load_context/2

Did you know ... Search Documentation:
SWI-Prolog owl logo Predicate prolog_load_context/2
Availability:built-in
Source prolog_load_context(?Key, ?Value)
Obtain context information during compilation. This predicate can be used from directives appearing in a source file to get information about the file being loaded as well as by the term_expansion/2 and goal_expansion/2 hooks. See also source_location/2 and if/1. The following keys are defined:
Key Description
directory Directory in which source lives (absolute path)
dialect Compatibility mode. See expects_dialect/1.
file Similar to source, but returns the file being included when called while an include file is being processed (absolute path)
module Module into which file is loaded
reload true if the file is being reloaded. Not present on first load
script Boolean that indicates whether the file is loaded as a script file (see -s)
source File being loaded (absolute path). If the system is processing an included file, the value is the main file. Returns the original Prolog file when loading a .qlf file.
stream Stream identifier (see current_input/1)
term_position Start position of last term read. See also stream_property/2 (position property and stream_position_data/3.59Up to version 7.1.22, the position term carried fake data except for the line_count and had five arguments, where the position property of a stream only has four.
term Term being expanded by expand_term/2.
variable_names A list of‘Name = Var’of the last term read. See read_term/2 for details.

The directory is commonly used to add rules to file_search_path/2, setting up a search path for finding files with absolute_file_name/3. For example:

:- dynamic user:file_search_path/2.
:- multifile user:file_search_path/2.
:- prolog_load_context(directory, Dir),
 asserta(user:file_search_path(my_program_home, Dir)).
 ...
 absolute_file_name(my_program_home('README.TXT'), ReadMe,
 [ access(read) ]),
 ...
Tags are associated to your profile if you are logged in
Tags:
login to add a new annotation post.

AltStyle によって変換されたページ (->オリジナル) /