October 31, 2025, 11:47:56 AM

News:

IWBasic runs in Windows 11!


Passing values from a dialog

Started by JoaoAfonso, May 09, 2008, 09:49:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JoaoAfonso

Good evening.

Another simple question, I guess (sorry the spam): using multiple dialogs, is there a way to pass values from one to other without using global variables?

Example:
I need to put information in dialog 1. To be more user friendly, to receive that information, dialog 1 opens dialog 2. When a button "ok" his hit in dialog 2, this one closes and the info set there is written in dialog 1 fields.

Thank you
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

Ionic Wind Support Team

Extend the dialog UDT

TYPE INFODLG
  DIALOG dlg
  STRING return1
  STRING return2
  STRING return3
  INT something
ENDTYPE

The magic rule is the first member of a UDT has the same address as the UDT itself. 

def idlg as INFODLG
CREATEDIALOG idlg.dlg, .....
...
DoModal idlg.dlg
print idlg.return1

The when processing @IDOK use a typecast to fill in members for the return.  Instead of #<WINDOW>@HITWINDOW use #<INFODLG>@HITWINDOW

case @idcontrol
    if @controlid = @IDOK
         #<INFODLG>@HITWINDOW.return1 = "hello there"

....

Now I mentioned the "magic rule".  I usually use NEW/DELETE and save the pointer to the original UDT as a property.   Which allows you to do things like:

pDlg = NEW(INFODLG, 1)
CREATEDIALOG #<DIALOG>pDlg
...
DoModal #<DIALOG>pDlg
...
DELETE pDlg

Paul
Ionic Wind Support Team

JoaoAfonso

Wow. Wonderful and fast :) Thank you!
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

Bruce Peaslee

I wish I know this years ago!   :D

Very useful.

Thanks, Paul.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

JoaoAfonso

Amazing. I am "translating" some big CB code to EB. This makes things so easy! :)
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

aurelCB

Do you writte converter from CB to EB with this?
If you do...
that would be wonderful!!!

JoaoAfonso

Figured out the "magic rule", which makes me do less changes :) Amazing. Paul, you have all knowledge in your head, or you check your documents and help files to answer us?
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

Ionic Wind Support Team

Mostly from the top of my head.  Sometimes have to look up an answer.
Ionic Wind Support Team

pistol350

Quote from: aurelCB on May 09, 2008, 11:54:13 AM
Do you writte converter from CB to EB with this?
If you do...
that would be wonderful!!!

Hi aurelCB!

there is already a IbstandardToPro converter.
see this link :
http://www.ionicwind.com/forums/index.php/topic,1644.msg15229.html#msg15229
Regards,

Peter B.

aurelCB

I forget answaer you...
I try this converter before , i try convert my interpreter
but im failed becose Ebasic say that dont suport local subroutine.

Bruce Peaslee

To me the real value of this technique is sending information into the dialog.


TYPE EXTENDEDDIALOG
   Dialog dlg 
   String msg
ENDTYPE
...
Def dlgAgendaItem as EXTENDEDDIALOG
...
Select @MENUNUM
   Case AGENDA_ITEM_EDIT
      dlgAgendaItem.msg = "Edit"
      DoModal dlgAgendaItem, dlgAgenda
   Case AGENDA_ITEM_NEW
      dlgAgendaItem.msg = "New"
      DoModal dlgAgendaItem, dlgAgenda
EndSelect
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles