Quintus Prolog Manual


(PREV) (NEXT)

g-3: Invoking Prolog

g-3-1: Prolog Command Line Argument Handling

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 {manual(g-5-4)}) or a stand-alone program (see {manual(STATIC-LINKING)}).
<Prolog's arguments> consists of:
<user's arguments>
these arguments can be retrieved in a program by calling unix(argv(ArgList)).
<system arguments>
The current valid system arguments are:
+
invoke Emacs; subsequent arguments passed to Emacs;
+f
fast startup; do not load user's prolog.ini file;
+l <file>
load the specified file on startup; <file> may be a Prolog file or a QOF file, and it may be specified either as a string (eg. 'file', '~/prolog/file.pl) or as a file search path specification (eg. '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>
like +l, but search for file in the directories given by the shell environment variable PATH; and
+p [<path-name>]
prints the Prolog file search path definitions that begin with the string <path-name> (eg. 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>]
same as +p, but the absolutized versions of the file search path definitions are printed;
+tty
force the three standard streams associated with a Prolog process to act as tty streams; a tty stream is usually line buffered and handles the prompt automatically;
+z
all subsequent arguments are user's arguments.

Only one of + or +z is possible on one command line.

<emacs' arguments>
arguments to the Emacs interface. This may include file names to edit and may also include GNU Emacs arguments (see {manual(d-2)}).

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 Unix 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)



g-3-1-1: The Initialization File

Once invoked, the default prolog looks in your home directory for a file named prolog.ini, and if it finds one, loads it. Stand-alone programs also look for and load prolog.ini. Runtime systems do not.

Typically, prolog.ini files are used to define file search paths, library directories, and term expansions.

If the +f option is specified, the initialization file prolog.ini is not loaded.

g-3-2: Exiting Prolog

To exit from the Prolog system, either type

        | ?- halt.



 

or your end-of-file character. The end-of-file character is ^d by default. You will use a different command set to exit Prolog running under Emacs; see {manual(d-2-2)}. The commands for exiting are as follows:

   
           without Emacs:  type '^d' (or '^C e'). You may

                                also execute the goal halt/0.

           with GNU Emacs: type '^c ^d' (or 'Escape-X

                          exit-emacs').

           with QUI:       Use Interrupt button in main window.

                           Select Exit.



   

If you would like to pause Prolog while keeping the job in the background:

   
without Emacs: type '^Z'.

with GNU Emacs: type '^X^Z'.

with QUI: iconify the main window



   


Copyright (C) 1997 AI International Ltd
contact: product support sales information