Compiling error

Discussions related to Visual Prolog
jeangil
Posts: 10
Joined: 8 Sep 2019 15:59

Compiling error

Unread post by jeangil » 25 Oct 2019 17:08

Hi,

I 'm new in VIP and I start to read and make exercise with "Visual Prolog for beginners".
I encounter a compilation pb with exercise with "GetString exercise (p38 of this book)".

(see code below from Taskwindows.pro)

Code: Select all

predicates       onMessagesGetstring : window::menuItemListener.   clauses        onMessagesGetstring(_Source, _MenuTag) :-        AnswerString = getString("Title", "Question", "Preset Answer"), !,        note("Your answer is ...", AnswerString).        [u]onMessagesGetstring[/u](_Source, _MenuTag) :-        note("You clicked the <Cancel> button").
When Building, it give me an error here (where it's underline ).

the compiling error is :
e283 Undeclared predicate or fact 'onMessagesGetstring/2' TaskWindow.pro TaskWindow\

I wonder if "onMessagesGetstring" still in use ?
Is there another instruction for this ?
By the way, could you tell me where I can find all the classes for VIP and their descriptions ?

Thanks you for your help.

Regards.

Jeangil

jeangil
Posts: 10
Joined: 8 Sep 2019 15:59

Re: Compiling error

Unread post by jeangil » 26 Oct 2019 13:46

Hi again,

Since my last post yesterday, I found why I got 'E283' error when building, it's because "getString" is in CGI class, which I add in my code (see code below),

But I got an other Code error when building e248 The clauses of the predicate 'onMessageGetstring/2' are not grouped together TaskWindow.pro TaskWindow\.

What does it mean ?
I don't know if I have to move something ?

Could you help ? :?

Regards

Jeangil

Code: Select all

predicates     onMessageGetstring : window::menuItemListener. clauses     onMessageGetstring(_Source, _MenuTag) :-         AnswerString = cgi::getString("Title", "Question", "Preset Answer"),         !,         note("Your answer is ...", AnswerString).     onMessagesGetstring(_Source, _MenuTag) :-         note("You clicked the <Cancel> button").

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

Re: Compiling error

Unread post by Harrison Pratt » 26 Oct 2019 15:58

(1) Try double-clicking on onMessagesGetstring to highlight it and then scroll up and down in the file to see if you have some other predicate's clauses between the onMessagesGetstring clauses. Perhaps you have another attempt at writing onMessagesGetstring that you forgot to delete or comment out.

(2) I don't have access to your VP book, but it seems unlikely that the cgi class would be used in an introductory text. Take a look at the vpiCommonDialogs class if you are writing a GUI program.

Code: Select all

vpiCommonDialogs::getString : (     string Title,     string Prompt,     string InitString)     -> string Response     determ.
If you are writing a console program take a look at the console class. There you will find useful predicates, including this:

Code: Select all

console::readLine : ()     -> string Value.

jeangil
Posts: 10
Joined: 8 Sep 2019 15:59

Re: Compiling error

Unread post by jeangil » 26 Oct 2019 17:03

Dear Harrison,

Thank you for your answer, compiling error is still there but I will look on vpiCommonDialogs class as you suggested.
Regards.

NB. could you tell me where I can find all vip Class ?

jeangil

jeangil
Posts: 10
Joined: 8 Sep 2019 15:59

Re: Compiling error

Unread post by jeangil » 26 Oct 2019 17:20

I mean "Class Documentation" place in wiki help.

Thank you.

jeangil

Martin Meyer
VIP Member
Posts: 289
Joined: 14 Nov 2002 0:01

Re: Compiling error

Unread post by Martin Meyer » 26 Oct 2019 17:45

In addition to what Harrison said a look into the Language Reference can help you. It says:
..., all clauses for one predicate/fact (the same name and arity) must be grouped together in one clauses section and without intervening clauses of other predicates/facts.
That means, allowed is:

Code: Select all

class predicates     myPredicateA : (). clauses     myPredicateA() :-         stdIO::write("am clause 1 of myPredicateA\n"),         fail.       myPredicateA() :-         stdIO::write("am clause 2 of myPredicateA\n").   class predicates     myPredicateB : (). clauses     myPredicateB() :-         stdIO::write("am clause 1 of myPredicateB\n"),         fail.       myPredicateB() :-         stdIO::write("am clause 2 of myPredicateB\n").
Also legal, but less clearly arranged, is:

Code: Select all

class predicates     myPredicateA : ().   class predicates     myPredicateB : ().   clauses     myPredicateA() :-         stdIO::write("am clause 1 of myPredicateA\n"),         fail.       myPredicateA() :-         stdIO::write("am clause 2 of myPredicateA\n").       myPredicateB() :-         stdIO::write("am clause 1 of myPredicateB\n"),         fail.       myPredicateB() :-         stdIO::write("am clause 2 of myPredicateB\n").
But illegal and resulting in the error you got is:

Code: Select all

class predicates     myPredicateA : ().   class predicates     myPredicateB : ().     clauses     myPredicateA() :-         stdIO::write("am clause 1 of myPredicateA\n"),         fail.       myPredicateB() :-         stdIO::write("am clause 1 of myPredicateB\n"),         fail.       myPredicateA() :-         stdIO::write("am clause 2 of myPredicateA\n").       myPredicateB() :-         stdIO::write("am clause 2 of myPredicateB\n").
Furthermore, when you want to look up a predicate declaration in VIP you can place the cursor on the predicate name and press Ctrl+F12 ("Go to Declaration"), or, if it is a PFC (Prolog Foundation Classes) predicate, you can hit F1 ("Context Help") to find it in the help file. The help file contains the class documentation of all PFC predicates.
Regards Martin

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

Re: Compiling error

Unread post by Harrison Pratt » 26 Oct 2019 18:04

Besides the wiki, a good way to search for built-in VIP predicates is using the the IDE project tree explorer.

In your project explorer expand the $(ProDir) directory and then expand the pfc directory. You will find many support classes there. Expand any of those that seem relevant (e.g., the string class, or the vpi class) and you will find the predicates etc. supported by that class.

Note that if you have not "built" the project you will only see the *.pack file in the directory. After you have built the project the .cl, .pro and (if relevant) the .i files will be visible.

If you click on one of the predicates in these files and press F1 then the HTML help file will open to show you more information.
Attachments
Ashampoo_Snap_Saturday, October 26, 2019_12h52m18s_006_.jpg
Ashampoo_Snap_Saturday, October 26, 2019_12h52m18s_006_.jpg (75.37 KiB) Viewed 405 times

jeangil
Posts: 10
Joined: 8 Sep 2019 15:59

Re: Compiling error

Unread post by jeangil » 26 Oct 2019 18:24

Many thanks to you,
for these useful informations :D

Regards

jeangil

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

Re: Compiling error

Unread post by Thomas Linder Puls » 28 Oct 2019 10:24

Please read about how to present code in Visual Prolog discussion forum.
Regards Thomas Linder Puls
PDC

Post Reply