Undeclared identifier & Undeclared fact

Discussions related to Visual Prolog
Loffy
Posts: 5
Joined: 15 Aug 2019 11:32

Undeclared identifier & Undeclared fact

Unread post by Loffy » 15 Aug 2019 12:13

Dear Sir/Madam,

I am new to Visual Prolog 9, but experienced at PDC prolog syntax.

I am not yet competent with the object oriented features of Visual Prog 9.

I have created a new project with class facts defined in a database in TaskWindow.pro. These facts can be manipulated as I wish.

I have created a dialog within the TaskWindow pack called "Prime". This dialog is intended to change the status of a database fact called "user". On compilation I get two types of errors.

1. The first error is "error c229 : Undeclared identifier 'gui_native::setRect/1', the identifier is known as 'setRect/5->' in the class 'gui_native'" and is located in automatically generated code in the module "prime.pro"

2. The second error relates to the definition of the facts. When I try to find/assert/retract a "user" fact in "prime.pro" generated in a dialog I get the error "e283 Undeclared fact 'user/4' prime.pro TaskWindow\dialogs\".

I am fairly sure that the second error relates to a problem with my understanding of the definition of my database which I am trying to declare as "global facts" in the old world of PDC Prolog. At least at this stage, I want to be able to access facts within this database from any dialog I create.

Regards,

Loffy

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

Re: Undeclared identifier & Undeclared fact

Unread post by Thomas Linder Puls » 15 Aug 2019 14:58

Welcome back :wink:.

In future please only have one problem in each mail. Mail threads becomes very complex when they are about several topics .

The first problem sounds very strange. Please post this problem in a new mail, and include there relevant code in that mail. I will consider that problem closed in this mail thread.

The second problem is clearly related to a difference between PDC Prolog "global facts" and Visual Prolog "class facts".

PDC Prolog global facts was directly accessible from the entire program. Such facts does not exist in Visual Prolog.

In Visual Prolog facts (i.e. class fact as well as object facts) are only visible in the implementation where they are declared. So if you want to manipulate them "globally" you must do so through a predicate that is implemented in the relevant class.

I suggest that you don't have such application data in the task window class. Let us instead place it in a userInfo class. To add a user (from anywhere in the program) we will add a addUser predicate:

Code: Select all

class userInfo   predicates     addUser : (string UserName).   end class userInfo
The predicate will be implemented in the corresponding userInfo implementation where we also have the facts:

Code: Select all

implement userInfo   class facts     user_fact : (string UserName).   clauses     addUser(UserName) :-         assert(user_fact(UserName)).   end implement userInfo
Regards Thomas Linder Puls
PDC

Loffy
Posts: 5
Joined: 15 Aug 2019 11:32

Re: Undeclared identifier & Undeclared fact

Unread post by Loffy » 16 Aug 2019 4:18

Thomas,

Thanks. I will try your suggestion later today.

I will send you a separate e-mail on the Undeclared identifier issue also later today. I have fixed the problem, but no doubt you will want to know what the problem was, and how it was fixed.

Regards,

Loffy

Post Reply