mIRC Home    About    Download    Register    News    Help

Print Thread
#156146 12/08/06 02:42 AM
Joined: Jul 2004
Posts: 21
X
xhine Offline OP
Ameglian cow
OP Offline
Ameglian cow
X
Joined: Jul 2004
Posts: 21
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?

#156147 12/08/06 03:26 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

#156148 12/08/06 03:53 AM
Joined: Jul 2004
Posts: 21
X
xhine Offline OP
Ameglian cow
OP Offline
Ameglian cow
X
Joined: Jul 2004
Posts: 21
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.

#156149 12/08/06 05:00 AM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
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)
}

#156150 12/08/06 05:22 AM
Joined: Jul 2004
Posts: 21
X
xhine Offline OP
Ameglian cow
OP Offline
Ameglian cow
X
Joined: Jul 2004
Posts: 21
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 ?

#156151 12/08/06 07:27 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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
  }
}


-KingTomato
#156152 12/08/06 07:40 AM
Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
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".


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
#156153 12/08/06 09:31 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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


Link Copied to Clipboard