mIRC Homepage

Conditional Statements in Dialog Tables?

Posted By: KubosKube

Conditional Statements in Dialog Tables? - 10/05/20 03:51 PM

I did some toying around before posting. I found that a dialog can use $iif to select between different values, and that you can use %global_variables to provide user-created data, but using a regular "if () {}" statement caused the dialog to stop working.

Are there workarounds to this? I've been wanting to work with this stuff for a while, but I just haven't gotten around to it until now, and I think it'd be rather useful.
Posted By: Wims

Re: Conditional Statements in Dialog Tables? - 10/05/20 04:15 PM

You cannot include code inside the dialog table, you can call $identifiers and variables though.

You can use the on dialog 'init' event name to set up initial values in your dialog.
Posted By: KubosKube

Re: Conditional Statements in Dialog Tables? - 10/05/20 09:55 PM

Okay, so for example, I want a dialog to range in size based on the presence of a remote script or not,

I can put conditional if statements or use $calc to add numbers or whatever, as long as the values are defined inside of the "on *:dialog:dialog_name:init: {}" code?

So then it looks like this:
Code
on *:dialog:dialog_name:init: {
  set %somevariable 10
  if (condition) { set %somevariable $calc(%somevariable + 10) }

dialog dialog_name {
  title "Test"
  size -1 -1 82 %somevariable
  option dbu
}


Does that look right?
Posted By: Wims

Re: Conditional Statements in Dialog Tables? - 10/05/20 10:05 PM

What I said was true for anything but the size, although for the size of the dialog, it's possible to put any value in the table and then user /dialog -s to resize the dialog from on on dialog 'init' event.
But controls cannot be resized/moved once they are created (at least not with only mIRC), so you do need to define their value in the table. You can use identifiers call to execute /if statement:


Code
alias mydialogheight {
if ($script(0) > 7) return 100
return 80
}
dialog dialog_name {
  title "Test"
  size -1 -1 82 $mydialogheight
}
© 2020 mIRC Discussion Forums