Command-Line Runtime Shell

Included in the src/acore/arun directory is the source code, arun.cpp. This is the source for the command-line interface runtime shell (arun[.exe]). It is a relatively simple Logic Server application.

Arun takes one argument, which is the name of a .xpl file. It initializes the Prolog environment, loads the named .xpl file, and calls its main/0 predicate. It then closes the Prolog environment.

You can modify arun.cpp to create your own command-line shell, or use it as a sample. It illustrates how to trap errors from a C++ program, and how to map command line arguments to Prolog so they can be retrieved by the Prolog program.

There is one tricky wrinkle in arun.cpp. If the name of the executable is not arun, then arun assumes its name is the same as the name of the .xpl file it is supposed to run. Huh? That's not as dumb as it seems, for you can make a copy of arun.exe, using the name of the .xpl file for the name of the new .exe. This lets you easily create executables for your application.

For example, if your Prolog program is ducks.xpl, you can copy arun.exe to ducks.exe. When you run ducks.exe it notices its name is not arun, so it runs ducks.xpl rather than reading the command line.

Copyright ©1987-2000 Amzi! inc. All Rights Reserved.

.