Using commandline arguments (see section 2.4), SWI-Prolog can be forced to load files and execute queries for initialisation purposes or non-interactive operation. The most commonly used options are -f file to make Prolog load an initialisation file, -g goal to define an initialisation goal and -t goal to define the toplevel goal. The following is a typical example for starting an application directly from the commandline.
machine% pl -f load.pl -g go -t halt
It tells SWI-Prolog to load
load.pl, start the
application using the entry-point go/0
and ---instead of entering the interactive toplevel--- exit after
In MS-Windows, the same can be achieved using a short-cut with
appropriately defined commandline arguments. A typically seen
alternative is to write a file
run.pl with content as
illustrated below. Double-clicking
run.pl will start the
:- [load]. % load program :- go. % run it :- halt. % and exit
Chapter 6 discusses the generation of runtime executables. Runtime executables are a mean to deliver executables that do not require the Prolog system.