A module is a file that has been loaded and compiled by the Prolog compiler, each module must have a different name (this name is not the same as the filename) that uniquely identifies the module. This name must be an atom. Each module also has an open-mode associated with it, this open-mode determines if a module may be saved or not. To specify the open-mode use one of the two atomic constants: read, or readwrite.
To open a module there are the following six built-in predicates:
| open_module. |
| open_module(<filepath-surrounded-by-(single)quotes>). |
| open_module(<internal-name>, <filepath-surrounded-by-(single)quotes>, <open-mode>). |
| consult. |
| consult(<filepath-surrounded-by-(single)quotes>). |
| consult(<internal-name>, <filepath-surrounded-by-(single)quotes>, <open-mode>). |
The open_module/0 and consult/0
predicates create and display a 'File Open' dialog window in which a file can be selected,
an internal name is automatically generated by Trinc-Prolog and the open mode is set to
readwrite. The open_module/1 and consult/1
predicates open a specified file, an internal module name is generated and the open mode
is also set to readwrite.
The module name, location of the file and the open mode can be specified with the
predicates consult/3 and open_module/3.
| Modules may also be compressed .gz files, Trinc-Prolog automatically detects compressed .gz files and decompresses them while loading. |
| open_module(m5, ;c:\\testcase\\cltest5.txt", read). |
| consult('c:\\prj\\cltest6.txt'). |
| consult. |
As can be seen from the example above two backslash characters are used to separate folders, two backslash characters are used to ensure that a part of a filename is not interpreted as an escape sequence, for instance each '\t' character sequence is replaced by the compiler by a single tab character.
| The two backslash characters are translated by the compiler to a single backslash character! |
After a file was successfully opened it becomes the active module. The active module is the module in which the Prolog interpreter start searching when a goal must be proven. For more information about this see set_active_module/0 or set_active_module/1. With active_module/1 it is possible to determine which module is the active module of the clausebase.
| A file can also be compiled by dragging it with the mouse and dropping it over the Output window or Modules window of Trinc-Prolog. |