1.5. 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
- to supply the full filename, including the
.pl extension
- the path from your $HOME directory to
the file
- enclose the whole expression in single quotes, like
this:
| ?- consult(‘myprolog/<filename>.pl’). <return>