mIRC Homepage
Posted By: xhine return from dialog - 12/08/06 02:42 AM
I create a dialog using
Code:
 $dialog(dname,dname,-4)
, but when I click the ok button, which I've labeled as result, nothing is returned.

Code:
   button "Yes", 2, 70 100 70 25, result ok 

that's basically the line in the dialog {} section. I expect it to return "Yes" but I'm guessing there is something I'm missing?
Posted By: RusselB Re: return from dialog - 12/08/06 03:26 AM
Code:
 on *:dialog:<dialog_name>:close:*:{
echo -a $did($dialog(<dialog_name>).result)
}
 


That should echo the word Yes in the active window when you press the button

I didn't know what you were wanting to do with that information, so I just echoed it.
Posted By: xhine Re: return from dialog - 12/08/06 03:53 AM
That does work, but I am trying to get the result in a different dialog. So when someone, for example, clicks the "add" button in dialog 1, it will create dialog 2 (which asks for certain info), and return the info. That is what I'm trying to accomplish.
Posted By: Rand Re: return from dialog - 12/08/06 05:00 AM
Sorry, but the function "return" can only return ONE string.

If you are calling another dialog to input information into it, and want that information to go into the other dialog, you simply do something like

Code:
on *:dialog:d2:sclick:200:{
  did -a d1 <ID> $did(d2,ID2)
  did -a d1 <ID> $did(d2,ID2)
}
Posted By: xhine Re: return from dialog - 12/08/06 05:22 AM
Err, not exactly what I had in mind. Let me try to be more specific.

When the user presses the "add" button on dialog 1, that dialog will create another dialog (a dialog to request input) and that 2nd dialog (that was created by dialog 1) will return back the input of the user.

So, something like:
Code:
if ($dialog(userinput,userinput,-4) == Yes) { etc.. }


Does that make more sense ?
Posted By: KingTomato Re: return from dialog - 12/08/06 07:27 AM
mIC doesn't work in the way other languages do. It can't call a dialog and hold processing for the return result. You need to use what Russel or Rand suggested. When th second dialog closes, return the information in the "on close event". I tend to make sure the dialog is open first. For example:

Code:
on *:DIALOG:[color:blue]info_dialog[/color]:close:*: {
  if ($dialog([color:blue]main_dialog[/color])) {
    /did -a [color:blue]main_dialog[/color] 100 blah blah
  }
}
Posted By: xDaeMoN Re: return from dialog - 12/08/06 07:40 AM
You can also use $input

Code:
 alias testinput {
  var %uc = $input(Press Yes or No?,uy, Blah blah)
  if ( $! ) {
    ;do stuff here if Yes
  }
  else {
    ; do stuff here if No
  }
}

on *:dialog:d1:sclick:200: .timer 1 0 testinput 


The above alias will give you an input dialog with Yes or No button. If you want to enter an information, add "e" to "uy".
Posted By: genius_at_work Re: return from dialog - 12/08/06 09:31 PM
Try this code:

Code:
alias myDialog { dialog -mv Dialog1 Dialog1 }
;
dialog Dialog1 {
  title "Dialog1"
  option dbu
  size -1 -1 50 50
  button "Yes/No", 100, 5 5 40 40
}
on *:DIALOG:Dialog1:sclick:100:{ echo -a Result is: $dialog(Dialog2,Dialog2,-4) }
;
dialog Dialog2 {
  title "Dialog2"
  option dbu
  size -1 -1 75 40
  [color:red]text "", 10, 0 0 10 15,result hide
  button "ok", 500, 0 0 1 1,hide ok[/color]
  [color:green]button "No", [color:blue]1000[/color], 5 5 30 30
  button "Yes", [color:blue]1001[/color], 40 5 30 30[/color]
}
on *:DIALOG:Dialog2:sclick:[color:blue]1000,1001[/color]:{
  [color:red]did -ra Dialog2 10 $did($did).text
  dialog -k Dialog2[/color]
}


I don't know why you can't return the results of a button, but this code should work for you.

The green text is the buttons that you can change/add/remove.
The blue are the dialog IDs that will cause a "result" when clicked.
The red portions are the workaround.

-genius_at_work
© mIRC Discussion Forums