Page 1 of 1
Compiling error
Posted: 25 Oct 2019 17:08
by jeangil
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
Re: Compiling error
Posted: 26 Oct 2019 13:46
by jeangil
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").
Re: Compiling error
Posted: 26 Oct 2019 15:58
by Harrison Pratt
(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.
Re: Compiling error
Posted: 26 Oct 2019 17:03
by jeangil
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
Re: Compiling error
Posted: 26 Oct 2019 17:20
by jeangil
I mean "Class Documentation" place in wiki help.
Thank you.
jeangil
Re: Compiling error
Posted: 26 Oct 2019 17:45
by Martin Meyer
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.
Re: Compiling error
Posted: 26 Oct 2019 18:04
by Harrison Pratt
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.
Re: Compiling error
Posted: 26 Oct 2019 18:24
by jeangil
Many thanks to you,
for these useful informations
Regards
jeangil
Re: Compiling error
Posted: 28 Oct 2019 10:24
by Thomas Linder Puls
Please read about how to present code in
Visual Prolog discussion forum.