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 on a networked Windows machine, use the following instructions. (In the elab, this has already been set up.)

  1. Start Prolog (by double-clicking the shortcut to plwin.exe on your desktop).
  2. From the Menu bar select  Settings|User init file
  3. Scroll down the file until you see  %:- set_prolog_flag(editor, pce_emacs).
  4. Delete the percentage sign at the beginning of the line.
  5. Save the file (Either Save from the File menu, or use the key combination Ctrl-x Ctrl-s — that is, hold down the Control key and type xs).
  6. Quit Prolog. Next time you start Prolog, the emacs editor will be available.

Here is how you create a Prolog program.

  1. Double-click the Prolog program icon.
  2. 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 in a location to which you are allowed to write files.
  3. If you are in the elab, you have two choices

    1. Save it to the elab server: <username> on ’jigsawxp1’ (U:). (Where <username> is your username.) The drawback to this is that your files are then only accessible from the elab computers.
    2. Save it on your networked filestore; it will then be accessible both from the elab and elsewhere on campu. To do this follow these instructions
      • From the Start menu, Choose My Network Places and then select Add Network Place from the pane on the left
      • This opens the Add Network Place Wizard; respond by clicking Next until you get the invitation to enter an Internet or network address.
      • Type \\userfs.york.ac.uk\<username> (where <username> is your username).
      • Your username should be entered in the form <username>@york.ac.uk
      • You will be able to access your network filestore via My Network Places.
  4. Enter the text of your file in the file window.
  5. 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.
  6. Make sure that you give your Prolog files the extension .pl .
  7. 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.
  8. The same procedures work in the SWI-Prolog window; select the text to copy and use Ctrl-y to paste.