Using command line 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 or -s file to make Prolog load a file, -g goal to define an initialisation goal and -t goal to define the top-level goal. The following is a typical example for starting an application directly from the command line.
machine% swipl -s 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 top level--- exit after completing go/0 . The
-q may be used to suppress all informational messages.
In MS-Windows, the same can be achieved using a short-cut with
appropriately defined command line 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
Section 188.8.131.52 discusses further scripting options, and chapter 11 discusses the generation of runtime executables. Runtime executables are a means to deliver executables that do not require the Prolog system.