Page 1 of 2

family1 example

Posted: 10 Oct 2017 22:39
by fviskovi
family1 does not produce the result that is indicated in the tutorial.

Posted: 11 Oct 2017 8:36
by Thomas Linder Puls
I get exactly the same result as in the tutorial, so you will have to provide more details.

Posted: 11 Oct 2017 17:07
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.

Posted: 12 Oct 2017 11:03
by Thomas Linder Puls
Please show me the "DOS gibberish".

Posted: 12 Oct 2017 15:13
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?

Posted: 12 Oct 2017 16:45
by Harrison Pratt
Can you send a screenshot using this technique?

https://www.howtogeek.com/226280/how-to ... indows-10/

Posted: 12 Oct 2017 21:05
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.

Posted: 13 Oct 2017 18:36
by fviskovi
I will try what you suggest.

Thanks for your help :D

Posted: 13 Oct 2017 22:15
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").

Posted: 13 Oct 2017 22:20
by fviskovi
Here is a screenshot. . . .

Posted: 14 Oct 2017 12:09
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().

Posted: 14 Oct 2017 18:58
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

Posted: 16 Oct 2017 18:52
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

Posted: 7 Nov 2017 16:34
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?

Posted: 8 Nov 2017 2:37
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: