Prolog: 'Hello world' resulting in existence_error. Have checked file paths with no success

221 views Asked by At

Here is my file:

image of notepad

Here is proof of where the file is located:

enter image description here

Here's what I typed into the GNU Prologue console:

| ?- change_directory('C:/Users/Aidan/Desktop/Prolog practice').

yes
| ?- [hello_world].

Expected result:

compiling C:/Users/Aidan/Desktop/Prolog practice/hello_world.pl for byte code...

Actual result:

uncaught exception: error(existence_error(source_sink,'hello_world.pl'),consult/1)

I have tried different file names, different folders, using the "consult" command, and using the absolute path instead of the filename. All result in the same error. Please help?

1

There are 1 answers

0
didou On

Windows native notepad is a simple text editor which tends to put .txt at the end of filenames. I suggest you to install another editor (e.g. notepad++).

Under Windows, gpolog allows you to consult a file with the File|Consult menu option which allows you to select the wanted file in a file selector dialog box. Then it emits a consult showing the real filename (check if there is a .txt a the end).

You can obviously consult it with passing the full pathname:

['hello_world.pl.txt'].

It is however better to rename your file with the extension .pl (or .pro). (The windows explorer has an option to hide known file extensions, maybe deactivate it to see full filenames including their extensions).

BTW, gprolog does not handle well spaces in filenames. I suggest you to rename your Prolog practice directory as Prolog-practice.