mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 129
A
AaronL Offline OP
Vogon poet
OP Offline
Vogon poet
A
Joined: Jan 2004
Posts: 129
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


Deridio fatum
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
You need 2 closing brackets, not one.
You need to close your "if ($devent == sclick) {"

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
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)
  }


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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 }
...


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Jan 2004
Posts: 129
A
AaronL Offline OP
Vogon poet
OP Offline
Vogon poet
A
Joined: Jan 2004
Posts: 129
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


Deridio fatum
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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)
    }
  }
}

Joined: Jan 2004
Posts: 129
A
AaronL Offline OP
Vogon poet
OP Offline
Vogon poet
A
Joined: Jan 2004
Posts: 129
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.

Last edited by AaronL; 29/03/07 02:55 PM.

Deridio fatum

Link Copied to Clipboard