mIRC Home    About    Download    Register    News    Help

Print Thread
#175427 22/04/07 04:45 PM
Joined: Mar 2007
Posts: 11
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Mar 2007
Posts: 11
Hi everyone,

I'm trying to make something for my script but it needs case sensitive letters, and I'm not sure how to do this??

on *:TEXT:w:#: { msg # This is a lower case w }
on *:TEXT:W:#: { msg # This is an upper case W }

when I type W in the room, it displays the "This is a lower case w" message.

How can I do this so it would be case sensitive??

Thanks to everyone in advanced!

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
The on TEXT event is not case sensitive. The easiest way to make a case sensitive script is something like this:

Code:
on *:TEXT:w:#:{
  if ($1 === w) ;lower case
  elseif ($1 === W) ;uppercase
}


The three === means case sensitive comparison.

-genius_at_work

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
on *:text:*:#: {
  if ($1 == $chr(119)) { msg $chan This is a lower case w }
  elseif ($1 == $chr(87)) { msg $chan This is an upper case W }
}


or...

Code:
on *:text:*:#: {
  if ($1- isupper) { echo -a This text is all upper case }
  elseif ($1- islower) { echo -a This text is all lower case }
}


or...

Code:
on *:text:w:#: {
  if ($1 isupper) { echo -a This is an upper case W }
  elseif ($1 islower) { echo -a This is a lower case w }
}


As a note, in this last code, you could just do:

Code:
else echo -a This is a lower case w


instead of the ELSEIF line. I showed you the ELSEIF line just so you can see how it works.

Personally, this third code is what I'd use.


Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: genius_at_work
The three === means case sensitive comparison.


So nice to learn something new. I didn't know that === did case sensitivity (not that I usually care about case sensitivity).


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2007
Posts: 11
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Mar 2007
Posts: 11
I didn't know about === either blush

Thanks everyone for a fast replys, and your help.
The codes is exactly what I've been looking for!

Thanks again for your help and time grin

Riamus2 #175436 22/04/07 05:37 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Your first code snippet won't work, $chr(119) is indistinguishable from "w" in scripts. When mirc compares the two characters for equality, it has no idea (ie it has 'forgotten') where that "w" came from, ie whether it came from $chr(119) or a hardcoded "w" or anything else.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
qwerty #175437 22/04/07 06:16 PM
Joined: Dec 2002
Posts: 2,033
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,033
Well yeah it should be...

if ($asc($1) == 119)

...but === is the best way to go anyway.


Link Copied to Clipboard