Discussions related to Visual Prolog
fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

family1 example

Unread post by fviskovi »

family1 does not produce the result that is indicated in the tutorial.
GDFBSN
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

I get exactly the same result as in the tutorial, so you will have to provide more details.
Regards Thomas Linder Puls
PDC
fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

Unread post by fviskovi »

I am using the Personal Edition of Visual PROLOG 8. I copied and pasted the exact code in the tutorial and then created the fa.txt file and added it. I am running it in Console Mode. I get a lot of DOS gibberish and then a PAUSE which if answered terminates the application.
GDFBSN
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

Please show me the "DOS gibberish".
Regards Thomas Linder Puls
PDC
fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

Unread post by fviskovi »

I can't copy the DOS gibberish. It's DOS.
What it looks like is the program is having trouble opening the fa.txt file. I created this file with NOTEPAD. I performed the FILE/ADD. Where should the file be located to facilitate getting it opened?
GDFBSN
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Unread post by Harrison Pratt »

Can you send a screenshot using this technique?

https://www.howtogeek.com/226280/how-to ... indows-10/
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

Before doing what I suggest below, please attach fa.txt here; I am curious about its format.

Secondly, try dropping the file on the IDE, so that it will open in our editor. If that works then make a change and save it again. That will change the file to utf-8 with an utf-8 byte-order-mark.
Regards Thomas Linder Puls
PDC
fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

Unread post by fviskovi »

I will try what you suggest.

Thanks for your help :D
Attachments
fa.txt
Here is the fa.txt file and where it was located.
(201 Bytes) Downloaded 476 times
GDFBSN
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Unread post by Harrison Pratt »

Try removing all the leading spaces before the facts.

Change the file from this:

Code: Select all

clauses     person("Judith",female).     person("Bill",male).     person("John",male).     person("Pam",female).     parent("John","Judith").     parent("Bill","John").     parent("Pam","Bill").
To this:

Code: Select all

clauses person("Judith",female). person("Bill",male). person("John",male). person("Pam",female). parent("John","Judith"). parent("Bill","John"). parent("Pam","Bill").
fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

Unread post by fviskovi »

Here is a screenshot. . . .
Attachments
Screenshot
Screenshot
Screenshot (1).png (99.62 KiB) Viewed 13919 times
GDFBSN
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Unread post by Harrison Pratt »

Make sure that you have saved the fa.txt file in the family1 subdirectory, not in the EXE directory. The error message indicates that the file is not found where specified.

Code: Select all

reconsult("..\\fa.txt"),  % leading "..\\" refers to the parent directory of the location where the family1.exe file is located.
Regarding my earlier comment about leading spaces. Testing the project in VIP 7.5 shows that leading spaces do NOT cause a problem when consulting a data file.

When I tested this project I added a line to the last run clause to pause the display:

Code: Select all

        run():-             stdIO::write("End of test\n"),             % NOTE: code below to pause output             _ = stdio::readLine().
fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

Unread post by fviskovi »

My problem is fixed. The example ran as it should. The move of the fa.txt file did the trick. I did not remove the leading spaces but it was stated that this shouldn't have mattered anyway.

Thanks everyone for their time, patience, and assistance. I appreciate it!!! Have a great weekend!!! 8-)

:D
GDFBSN
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

Notice that the "DOS gibberish" describe the problem quite precisely:
Cannot create or open '..\fa.txt'
Error = 00000002
The system cannot find the file specified
Regards Thomas Linder Puls
PDC
fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

Unread post by fviskovi »

I tried to change a few names in the fa.txt file. I saved the new file but it keeps accessing the original. I checked the fa.txt in the IDE and it shows my change. (I changed the name "Judith" to "Joyce") Why is it still picking up the old version with Judith? The program runs OK but I can't get the data modified. Where exactly should the fa.txt file reside?
GDFBSN
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Unread post by Harrison Pratt »

If your code is unchanged from what you posted previously, then it is in your project directory:

Code: Select all

reconsult("..\\fa.txt")
Compare the time-stamps of the fa.txt file in the EXE directory and your project directory using Windows Explorer. The one you changed last is probably the one you want to edit.

It's almost always found in the last place you look. :wink:
Post Reply