Information Technology Reference
In-Depth Information
Figure B.1.
An AppleScript for SWI-Prolog
on run
set prolog to "/opt/local/bin/swipl"
set myprompt to "Where do you keep your Prolog programs?"
set dir to POSIX path of (choose folder with prompt myprompt)
tell application "Terminal"
activate
do script "cd \"" & dir & "\"; " & prolog in window 1
end tell
end run
With Mac OS X
Unfortunately, running SWI-Prolog with a Mac is not as easy as it could be. It is best
to begin by preparing an AppleScript. Start the AppleScript Editor (often located in
the Utilities folder within the Applications folder). In the untitled window that
it presents, insert the text from the figure B.1 exactly as is. (The text can be cut and
pasted from the file applescript.txt that is on the topic website. See appendix A.)
Then do a “Save As” to save the script: choose the file format “application,” use a
name like “Start-SWI,” and save it to your desktop.
Once “Start-SWI” has been saved, Prolog can be used as follows:
1.
To start Prolog, double-click the “Start-SWI” icon on your desktop.
2.
It will ask you where you keep your Prolog programs. Navigate to a folder, such
as the folder that contains family.pl , and hit the “Choose” button.
3.
From within Prolog, you can now load any Prolog program in that folder by
using the square bracket notation (as done in figure 3.2).
4.
When you are done with Prolog, quit the Terminal application.
With Linux
After installing SWI-Prolog, there should be a binary called swipl . To use it, first
connect using cd to the directory that contains your Prolog programs like family.pl ,
and then start Prolog. From there, interact with Prolog, as shown in figure 3.2.
Search WWH ::




Custom Search