family1 example

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

family1 example

Post by fviskovi » 10 Oct 2017 22:39

family1 does not produce the result that is indicated in the tutorial.
GDFBSN

User avatar
Thomas Linder Puls
VIP Member
Posts: 2327
Joined: 28 Feb 2000 0:01

Post by Thomas Linder Puls » 11 Oct 2017 8:36

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

Post by fviskovi » 11 Oct 2017 17:07

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: 2327
Joined: 28 Feb 2000 0:01

Post by Thomas Linder Puls » 12 Oct 2017 11:03

Please show me the "DOS gibberish".
Regards Thomas Linder Puls
PDC

fviskovi
Posts: 8
Joined: 10 Oct 2017 22:35

Post by fviskovi » 12 Oct 2017 15:13

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: 257
Joined: 5 Nov 2000 0:01

Post by Harrison Pratt » 12 Oct 2017 16:45

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: 2327
Joined: 28 Feb 2000 0:01

Post by Thomas Linder Puls » 12 Oct 2017 21:05

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

Post by fviskovi » 13 Oct 2017 18:36

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 27 times
GDFBSN

Harrison Pratt
VIP Member
Posts: 257
Joined: 5 Nov 2000 0:01

Post by Harrison Pratt » 13 Oct 2017 22:15

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

Post by fviskovi » 13 Oct 2017 22:20

Here is a screenshot. . . .
Attachments
Screenshot (1).png
Screenshot
Screenshot (1).png (99.62 KiB) Viewed 671 times
GDFBSN

Harrison Pratt
VIP Member
Posts: 257
Joined: 5 Nov 2000 0:01

Post by Harrison Pratt » 14 Oct 2017 12:09

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

Post by fviskovi » 14 Oct 2017 18:58

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: 2327
Joined: 28 Feb 2000 0:01

Post by Thomas Linder Puls » 16 Oct 2017 18:52

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

Post by fviskovi » 7 Nov 2017 16:34

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: 257
Joined: 5 Nov 2000 0:01

Post by Harrison Pratt » 8 Nov 2017 2:37

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