2.11.2 For running the result
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Overview
        • Compilation
          • For running the result
            • Using PrologScript
            • Creating a shell script
            • Creating a saved state
            • Compilation using the -c command line option
    • Packages

2.11.2.2 Creating a shell script

With the introduction of PrologScript (see section 2.11.2.1), using shell scripts as explained in this section has become redundant for most applications.

Especially on Unix systems and not-too-large applications, writing a shell script that simply loads your application and calls the entry point is often a good choice. A skeleton for the script is given below, followed by the Prolog code to obtain the program arguments.

#!/bin/sh

base=<absolute-path-to-source>
PL=swipl

exec $PL -q -f "$base/load" --
:- initialization go.

go :-
        current_prolog_flag(argv, Arguments),
        go(Arguments).

go(Args) :-
        ...

On Windows systems, similar behaviour can be achieved by creating a shortcut to Prolog, passing the proper options or writing a .bat file.