next up previous contents
Next: Quitting Prolog Up: Running a Prolog program Previous: Tracing   Contents

A note on filenames and directories in Prolog

You may be in the (good) habit of organising your work by putting material related to a particular topic into a (sub-)directory. If you decide to do this with your Prolog files, you need to be aware of difference in the way you specify the filename using consult.

If the file is in the root directory of your M drive, and the file has the form <filename>.pl, you simply type

| ?- consult(<filename>). <return>
If, however, you have created a directory called, say myprolog and your file <filename>.pl lies inside that directory, the above instruction will not work and you will receive an error message.

What you have to do is:

  1. to supply the full filename, including the .pl extension

  2. the path from your $HOME directory to the file

  3. enclose the whole expression in single quotes, like this:
    | ?- consult('myprolog/<filename>.pl'). <return>
    



Steve Harlow 2001-11-12