1.2 Creating a Prolog program.
To create a Prolog program, you must use an editor to create a file. There are a
number of editors available and you can use whatever you prefer. If you have no
preference, I suggest using the emacs editor that comes with SWI-prolog. It is
Prolog-aware and will format and colour-code Prolog programs for you, as
well as providing a number of other Prolog-related conveniences. To use
emacs,
- Start Prolog
- From the Menu bar select Settings|User init file
- Scroll down the file until you see
%:- set_prolog_flag(editor, pce_emacs).
- Delete the percentage sign at the beginning of the line.
- Save the file (Either Save from the File menu, or use the key combination
Ctrl-x Ctrl-s).
- Quit Prolog. Next time you start Prolog, the emacs editor will be available.
Here is how you create a Prolog program.
- Double-click the Prolog program icon.
- Use the File menu of the resulting window to create a new file and give it
a name, with the extension .pl, making sure you save it at the root level
of your M drive. .
- Enter the text of your file in the file window.
- You save your file by using the Save option from the File menu on the
menu bar at the top of the editor’s window.
- Make sure that you give your Prolog files the extension .pl .
- You can copy text in the usual manner by using Copy and Paste from
the Edit menu, or by selecting the text with the cursor (this copies
automatically) and using using the key combination Ctrl-y to paste.
- The same procedures work in the SWI-Prolog window; select the text to
copy and use Ctrl-y to paste.