The predicate open_module_search is the same as open_module/3 but instead of an absolute path to a file a relative path can be specified. The predicate uses the relative path to search for the file starting at the location of the Trinc-Prolog executable which is interpreting the prolog program, to the root folder. For example, if the goal is:
| open_module_search(test, "test\test1.txt", read). |
and the Trinc-Prolog executable is located at "c:\Program Files\Trinc\Trinc Prolog\Program" then the following paths are searched for the file test1.txt:
| c:\Program
Files\Trinc\Trinc-Prolog\program\test\test1.txt c:\Program Files\Trinc\Trinc-Prolog\test\test1.txt c:\Program Files\Trinc\test\test1.txt c:\Program Files\test\test1.txt c:\test\test1.txt |
If this
predicate and open_standardmodule/2 are used a prolog program is
not dependant on a specific location for it to function properly.
The third argument can either be a single open-option or a list of open-options. The available options are:
It is possible to use a relative path name to open a file if open_module_search/3 is used inside a file that has been compiled. The relative path is combined with the path of the file in which the call to consult/1 resides to load the file specified. When specifying a filename put two backslash characters for each normal backslash in the filename, otherwise the character sequence could be mistaken for a symbolic control character like for instance: \t, which is replaced by a single tab character.
In Trinc-Prolog R3B this built-in predicate was expanded with the possibility that the third argument can be a list of open-options. The open-option 'not_active' was added. The exception 'domain_error(module_mode, A)' was replaced by the exception 'domain_error(consult_option, A)'.
see also: active_module/1 check_singleton/1 close_all_modules/0 close_module/1 consult/0 consult/1 consult/3 create_module/1 create_module/2 ensure_loaded/1 include/1 module/3 module_name/2 modules open_module/0 open_module/1 open_module/3 open_standard_module/2 save_module/1 save_module/2 save_module/3 set_active_module/0 set_active_module/1 this_module/3
| Exceptions | |
| any of the arguments is a empty variable | instantiation_error |
| one or both of the first and third arguments are not an atom | type_error(atom, A) |
| the second argument is not an atom enclosed by single or double quotes | type_error(atom_doublequoted, A) |
| the second argument is an atom not enclosed by single quotes | type_error(atom_singlequotes, A) |
| Invalid open-option specified | domain_error(consult_option, A) |
| the same file is already open or there is already a module with the same name | existence_error(module, A) |
| the file cannot be opened | existence_error(module_file, A) |
| one or more errors found in the module being opened | compile_error(module, A), A is replaced by the internal of the module |