mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 5
T
Timwi Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2003
Posts: 5
Consider the following script:

on ^*:HOTLINK:*:*:{
return
}

on *:HOTLINK:*:*:{
if (*a* iswm $1) {
echo a is in it
} else {
echo a is not in it
}
}

Whenever you double-click on a word, this should now display "a is in it" or "a is not in it", depending on whether the word contains an a.

However, if it does contain an a, both messages are printed.

In order words, the "else" branch is processed even if the condition was true. This seems to be true of any if-else statement I try.

Thanks

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
It's just the way you have formatted it, Try...
Code:
on ^*:HOTLINK:*:*:{
  return 
}

on *:HOTLINK:*:*:{
  if (*a* iswm $1) {
    echo a is in it
  }
  else {
    echo a is not in it
  }
}

Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Just to extend on Iori's post, you need to have either else ona new line, or use a | between the closing brace and the else. Example:

Code:
/test {
  if (*a* iswm $1-) {
    /echo -a There is an a!
  }
  else {
    /echo -a There is no a!
  }
}


Code:
/test {
  if (*a* iswm $1-) {
    /echo -a There is an a!
  } [color:red]|[/color] else {
    /echo -a There is no a!
  }
}


Same goes for else if >:D


-KingTomato
Joined: Sep 2003
Posts: 5
T
Timwi Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Sep 2003
Posts: 5
Thanks for your help!

I still think it's a bug though ;-) If it's invalid syntax, it should complain, instead of just processing it.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
It is a kind of bug in that mIRC recognizes the /else as a command but not as a statement. Also there's a bug in the script editor - it incorrectly indents the lines if you use a multi-line else, but indents correctly with a single-line else.

eg.
Code:
on *:HOTLINK:*:*:{
  if (*a* iswm $1) {
    echo a is in it
    } else { [color:orange]<- Still indented[/color]
    echo a is not in it
  }
}

on *:HOTLINK:*:*:{
  if (*a* iswm $1) {
    echo a is in it
  } else echo a is not in it [color:orange]<- Correctly indented[/color]
}


Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard