Basic Information

Once a program has been loaded, its facts and rules are resident in the Prolog database. It is possible to save the current state of the database in its compiled form as a QOF file. This allows you to restore the current database at a later time without having to re-compile your Prolog source files.

The built-in predicate save_program/1 saves the Prolog state. For example,

     | ?- save_program(myprog).
     

You can later reload the file myprog into Prolog using the command

     | ?- [myprog].
     

A saved program is a special kind of QOF file, which is capable of being run directly from the operating system, as if it were an executable file. To run a saved program from the command prompt, type the name of the file containing the saved program at the command prompt. For example,

     % myprog
     

This is equivalent to starting up Prolog and loading myprog. Under Windows, this only works if the name of the file has the extension bat, e.g. myprog.bat.

You can also specify a goal to be run when a saved program is started up. This is done by:

     | ?- save_program(myprog, start).
     

where start/0 is the predicate to be called.