mIRC Homepage
Posted By: AaronL Strange reaction on ' on *:dialog:setup....' - 26/03/07 07:13 AM
I get a strange recation on the following code:

if ($devent == sclick) {
if ($did == 411) {
if (%janeekleur == ON) { set %janeekleur OFF | /strip -c | echo -a System: Colored text allowed | halt }
if (%janeekleur == OFF) { set %janeekleur ON | /strip +c | echo -a System: Colored text refused | halt }
}
followed by a } to close the dialog.

when i click on the check then the line is followed, however.. if the %janeekleur is ON then it should be set to OFF, and there's my problem for it does'nt.
Dunno whats wrong with the code.



Greetz
Aaron
You need 2 closing brackets, not one.
You need to close your "if ($devent == sclick) {"
Try this

Code:
if ($devent == sclick) {
  if ($did == 411) {
    var %s = $iif($did(411).state,ON,OFF)
    set %janeekleur %s
    strip $iif(%s == on,+c,-c)
    echo -a System: Colored text $iif(%s == on,allowed,refused)
  }
Keep in mind that mirc processes commands line by line, in top-to-bottom order. If the variable is set to ON, the 3rd /if statement sets it to OFF (and also does strip -c etc). So as soon as the 3rd statement ends, the variable is equal to OFF.

As long as the 3rd /if statement finishes, mirc carries on with the next line of code, which is another /if statement that checks for the variable being OFF. Since the variable was set to OFF by the previous statement, the check succeds and the variable is set to ON again.

This is exactly where /elseif comes in handy:
Code:
...
if (%janeekleur == ON) { set %janeekleur OFF | /strip -c | echo -a System: Colored text allowed | halt }
elseif (%janeekleur == OFF) { set %janeekleur ON | /strip +c | echo -a System: Colored text refused | halt }
...
Well, i tried both solutions, but it still doesn't work.
So i give the whole (small) routine..
(dunno how to put it in code sorry for that)

on *:DIALOG:setup:*: {

if ($devent == init) {
if (%janeekleur == ON) { did -c setup 411 }
}

if ($devent == sclick) {
if ($did == 411) {
var %s = $iif($did(411).state,ON,OFF)
set %janeekleur %s
strip $iif(%s == on,+c,-c)
echo -a System: Colored text $iif(%s == on,allowed,refused)
}
}
}

i used the part from xDaemon. thanks xDaemon. smile
Please use the Code Tags when posting code. Currently the button for Code Tags looks like #

Regarding your problem, One thing I noticed, is that your ON DIALOG event is missing a parameter

Here's a re-write of your code, combining what you've presented in your posts and my own knowledge
Code:
ON *:DIALOG:setup:*:*:{
  if $devent == init {
    did $iif(%janeekleur == ON,-c,-u) setup 411
  }
  if ($devent == sclick) {
    if ($did == 411) {
      set %janeekleur $iif($did(411).state,ON,OFF)
      .strip $iif($did(411).state,+c,-c)
      echo -a System: Colored text $iif($did(411).state,refused,allowed)
    }
  }
}
Hi RusselB

Sorry for didn't using the code tags for which i thought it was
i used your code and its working now.
Thank you very much

Greetz
Aaron

ps. rembered the codetags again.
© mIRC Discussion Forums