This predicate can be used for opening a file containing prolog text and loading it into memory (the text is compiled while loading). The argument is a filename enclosed by single or double quotes. A module name is generated and the open-mode will be readwrite. The last opened or created module becomes the active module of the clausebase.
It is possible to use a relative path name to open a file if consult/1 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.
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/3 open_module_search/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
| Examples | |
| open_module("c:\\temp\\st23.txt"). | open the module located at the position "c:\temp\st23.txt" with the open-mode readwrite, the module is then identified by the name st23 |
| Exceptions | |
| the argument is a empty variable | instantiation_error |
| the Filename argument is not an atom | type_error(atom, Filename) |
| the Filename argument is not an atom enclosed by single or double quotes | type_error(atom_doublequoted, Filename) |
| the Filename argument is an atom not enclosed by single quotes | type_error(atom_singlequotes, Filename) |
| 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 |