There are three ways a Prolog system can be invoked:
% program Prolog's arguments % program Prolog's arguments + emacs' arguments % program Prolog's arguments +z user's arguments
where program, generally prolog
, but can be an executable
QOF file (see ref-sls-sst) or a stand-alone program (see
sap-srs).
unix(argv(ArgList))
.
+
+f
prolog.ini
file;
+l
file
file
, ~/prolog/file.pl
) or as a file search path specification
(e.g. library(file)
, home(language(file))
); note, however, that the
latter needs to be quoted to escape
the shell interpretation of the parentheses; giving the extension is not
necessary; if both source (.pl
) and QOF (.qof
) files exist, the
more recent of the two will be loaded;
+L
file
+l
, but search for file in the
directories given by the shell environment variable PATH
; and
+p [
path-name]
library
if
+p lib
is specified); path-name is optional, and if not given,
causes prolog to print all file search path definitions; prolog exits
after producing the required output to stdout
;
+P [
path-name]
+p
, but the absolutized versions of the
file search path definitions are printed;
+tty
+z
Only one of +
or +z
is possible on one command line.
All command line arguments beginning with a +
are reserved for
system arguments. If user arguments need to begin with a +
, they
should be given as ++
instead. The ++
is converted into a
single +
by the argument handling routines, and thus, to the
user's code, only the single +
argument is visible. An exception
to this is when an argument is given following a +z
option in
which case no conversion is done.
Runtime systems do not interpret system arguments; they treat all arguments as user's arguments.
There can be any number of +l
and +L
arguments. In Release 3,
invoking a saved-state, an executable QOF-file, as a
command causes the
corresponding Prolog executable, the one from which the saved-state was
created, to be invoked with the arguments +L
saved-state.
The user's arguments are accessible in Prolog via unix(argv(ArgList))
, which
returns a list of all the user's arguments. For example, if Prolog is
invoked by the command (A), then the Prolog goal (B) returns (C):
% prolog ++file1 -file2 (A)
| ?- unix(argv(ArgList)). (B)
ArgList = ['+file1','-file2'] (C)