IonicWind Software

IWBasic => General Questions => Topic started by: JoaoAfonso on May 09, 2008, 09:49:36 AM

Title: Passing values from a dialog
Post by: JoaoAfonso on May 09, 2008, 09:49:36 AM
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
Title: Re: Passing values from a dialog
Post by: Ionic Wind Support Team on May 09, 2008, 10:08:17 AM
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
Title: Re: Passing values from a dialog
Post by: JoaoAfonso on May 09, 2008, 10:12:21 AM
Wow. Wonderful and fast :) Thank you!
Title: Re: Passing values from a dialog
Post by: Bruce Peaslee on May 09, 2008, 10:19:11 AM
I wish I know this years ago!   :D

Very useful.

Thanks, Paul.
Title: Re: Passing values from a dialog
Post by: LarryMc on May 09, 2008, 11:23:51 AM
Quote from: peaslee on May 09, 2008, 10:19:11 AM
I wish I know this years ago!   :D

Me too!

Larry
Title: Re: Passing values from a dialog
Post by: JoaoAfonso on May 09, 2008, 11:30:03 AM
Amazing. I am "translating" some big CB code to EB. This makes things so easy! :)
Title: Re: Passing values from a dialog
Post by: 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!!!
Title: Re: Passing values from a dialog
Post by: JoaoAfonso on May 09, 2008, 12:12:47 PM
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?
Title: Re: Passing values from a dialog
Post by: Ionic Wind Support Team on May 09, 2008, 12:39:28 PM
Mostly from the top of my head.  Sometimes have to look up an answer.
Title: Re: Passing values from a dialog
Post by: pistol350 on May 11, 2008, 01:27:32 PM
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
Title: Re: Passing values from a dialog
Post by: aurelCB on May 12, 2008, 05:25:30 AM
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.
Title: Re: Passing values from a dialog
Post by: Bruce Peaslee on August 08, 2009, 03:47:19 PM
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