mIRC Home    About    Download    Register    News    Help

Print Thread
#32574 27/06/03 03:52 AM
Joined: Jun 2003
Posts: 13
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Jun 2003
Posts: 13
Is there a reason why the follow code doesn't work correctly?

Code:
  if (($left($1-,1) != !) || ($left($1-,1) != /)) {


If i take each statement and put it in its own line then it works fine..

#32575 27/06/03 03:55 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
The statement works fine for me..
Code:
/mooshasta {
  if (($left($1-,1) != !) || ($left($1-,1) != /)) {
    echo -a a
  }
}

Always echoes a, since one of the 2 conditions is always met..what's the problem?

#32576 27/06/03 03:55 AM
Joined: Dec 2002
Posts: 32
S
SyN Offline
Ameglian cow
Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 32
curious I'd probably use the $asc() values myself as they are often use as control charecters


It's only called insanity if you're poor.
I stay alive to spite those that wish me dead.
#32577 27/06/03 04:04 AM
Joined: Jun 2003
Posts: 13
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Jun 2003
Posts: 13
here's the full code its coming from...

Code:
on *:input:*: {
  if (($left($1-,1) != !) || ($left($1-,1) != /)) {
    if (%color = true) {
      var %output
      var %mod
      var %n = 1
      var %t
      var %string = $replace($1-,$chr(32),$chr(1000))

      :colorloop
      %mod = $calc(%n % 2)
      %t = $mid(%string,%n,1)
      if (%mod == 0) {
        set %output %output $+ 03 $+ %t
      }
      else {
        set %output %output $+ 04 $+ %t
      }
      inc %n
      if (%n <= $len($1-)) goto colorloop
      msg $active $replace(%output,$chr(1000),$chr(32))
      halt
    }
  }
}


the problem is that it still colors the text even if ! or / is the firsts character. if i remove either one of the conditions from the statement, it works fine.

#32578 27/06/03 04:06 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
Use && instead of ||.

#32579 27/06/03 04:08 AM
Joined: Jun 2003
Posts: 13
M
Pikka bird
OP Offline
Pikka bird
M
Joined: Jun 2003
Posts: 13
i cant believe i missed that. wow i feel stupid XD

thanks

#32580 27/06/03 04:33 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
I was just about to say thst. Putting each on their own line would infer both are to be true--making the || && instead. >:D


-KingTomato
#32581 27/06/03 05:10 AM
Joined: Jun 2003
Posts: 114
T
Vogon poet
Offline
Vogon poet
T
Joined: Jun 2003
Posts: 114
Umm, I'm mainly posting this to raise my number of posts. Getting close to 100 and all that....

Anyway, it does help if you read compound if statements out... at least for me. And replace (==) with is and (!=) with is not just to make it sound more..English.

If the first letter of the first word is not ! or it is not / then...

See, when you read it like that it just..sounds wrong somehow. Gramatically incorrect or something to have a sentence like that. Replace the or with and makes it sound better....

Or I might be crazy. Thats very possible.


-------------
I am the self-appointed God of needlessly complex mIRCscript.

Link Copied to Clipboard