Discussions related to Visual Prolog
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

How to recover the contein of and editControl in form2 from an other form ?

Unread post by Tonton Luc »

Hi,

Sorry, I don't remember how to do it.
Any sample ?

If my application have 2 forms (form1 + form2), and form2 have un editControl, how to recover the text of this editControl from a button in form1 ?
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

I think it sounds like a quite strange thing to do.
  • What should happen if form1 is not open?
  • What should happen if there are two or more form1's open?
But anyway, your form1 interface should provide a predicate that an obtain the value of the edit control.

And then (and this where the questions above come in play) form2 should obtain the "relevant" form1 object somewhere and call the predicate from above.
Regards Thomas Linder Puls
PDC
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc »

Hummm... it's not clear for me.
I try to explain more.

From his onShow, the taskwin open the form1.

When the user click to the task menu, the taskwin display form2 and put it BringToTop (so form1 never closed).

I this case, how to obtein the contain of an editControl of form2 from form1 ?
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

As mentioned above form1 should provide a predicate that can return the text:

Code: Select all

interface form1 supports form ... predicates     getEditControlText : () -> string Text. ... end interface   implement form1 ...   clauses     getEditControlText() = editControl_ctl:getText(). ... end implement form1.
That is the simple part, the difficult part is how form2 should obtain form1, because in generel there are nothing that guarenties that there is one and only one instance of a certain form.

Your program may of course have some special properties that ensures that there is exactly one form1 open. But it will require that form1 cannot be closed, and that additional form1's cannot be opened.

In that case it seems relatively safe to assert the form in a class fact somewhere so that form2 can access it through that fact.
[/list]
Regards Thomas Linder Puls
PDC
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc »

Hi,

Asserting the form in a class fact => it was what I'm looking for.
All works fine now.

Many thanks Thomas.
:wink:
Post Reply