mIRC Home    About    Download    Register    News    Help

Print Thread
#175427 22/04/07 04:45 PM
S
simons354
simons354
S
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!

#175430 22/04/07 04:54 PM
Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
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

#175431 22/04/07 04:55 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
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.

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
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).

#175433 22/04/07 05:06 PM
S
simons354
simons354
S
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,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
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.

qwerty #175437 22/04/07 06:16 PM
Joined: Dec 2002
Posts: 1,995
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 1,995
Well yeah it should be...

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

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


Link Copied to Clipboard