Discussions related to Visual Prolog
Michel
Posts: 9
Joined: 8 Nov 2025 17:17

some help about OOP

Post by Michel »

Hi,
I am not new to Prolog ( Turbo Prolog 1 and then Turbo Prolog 2 ) and I like it. I am a good "C" programmer ( classic K&R ) and I like it but, in fact, I dislike OOP which give me nightmares.

If in one file ( say "mydialog.pro" ) I declare two radioButton ( radioButton_ctl, radioButton2_ctl) for exemple.

From inside "mydialog.pro" if I want to enable/disable each of one or the two, I don't have any problem but if I want to get the same action, externaly, from say "mytwo.pro", I get issue(s)

Even if I declare a predicate in "mydialog.pro" called from "mytwo.pro", I obtain a result like

"error c229 : Undeclared identifier 'mydialog::radioButton_ctl'" :?

The calling predicate acts correctly ( tested with a simple call to a message ), inside "mydialog.pro" the two radioButtons seems to be unknown even declared correctly as they works fine.

I read and re-read tips and tricks, forums to find alone a solution but, at this time, I don't feel comfortable with OOP, sorry.

Visual P. is a VERY powerfull soft, the IDE is perfect, it compiles very fastly and the "*.exe" is light but, in fact, the problem is me.

Here is screen part of my medical ( homeopathic ) program in development...

Warm regards
Michel (from France).
You do not have the required permissions to view the files attached to this post.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1494
Joined: 28 Feb 2000 0:01

Re: some help about OOP

Post by Thomas Linder Puls »

Yes, I can see that there are a number of fundamental things you need to learn. The purpose of it all is of course not just to make it more complicated. There are also benefits.

For dialogs then main benefit is that you can have several dialogs of the same kind at the same time.

Your dialog has a corresponding "mydialog" object. And the radioButton_ctl is stored inside this object.

All data is by default hidden from external manipulation; it can only be manipulated from the code inside the mydialog implementation.

To manipulate it from outside you will have to expose something on the object, by declaring it in the objects interface (in mydialog.i).

In this case you can choose to expose the entire radioButton_ctl as a readable property. (I would probably expose something more "narrow").

It will look like this:

Code: Select all

interface mydialog ... properties     radioButton_ctl : radioButton (o). ...
Now you can enable/disable the button from outside, like this:

Code: Select all

    ...     MyDialog = mydialog::new(Parent),     MyDialog:radioButton_ctl:setEnabled(false),     MyDialog:show(),     ...
You will need access to the object that represents the dialog (the mydialog object) in the code above it is done through the MyDialog variable.

From your image I guess that you want to control a button on the first dialog from the second dialog. To do this you will have to pass "This" in the first dialog to the second dialog, and make the change through the received object (of type mydialog).

Code: Select all

clauses     onMyDialogButtonX(...) :-             Parent = This,             MyDialog = This, %This argument is for accessing radioButton_ctl             Second= mysecondDialog::show(Parent, MyDialog),             ...
The two variables Parent and MyDialog are just used to give the arguments a name.
Regards Thomas Linder Puls
PDC