mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2016
Posts: 2
L
LiozH Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
L
Joined: Feb 2016
Posts: 2
Hey guys, I have little to no experience with this language, but I'm managing to temper with code well enough.

I'm trying to write to commands that will search a text file for a specific text entered by a user and input that text into a variable, but I want the search to be case insensitive.

current code looks like this:

Code:
var %song $2-
%song = $read(Catalog.txt, nr, %song)


$2- is the string of text input by the user
The text file is a list of songs, each song in a different line, words starting with capital letters.

At the moment it works perfectly fine. Thing is it can only find the text i want if I use upper case letters correctly. How can I make it case insensitive? Thx in advance.

Last edited by LiozH; 01/02/16 02:15 PM.
Joined: Jul 2006
Posts: 4,211
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,211
$read by default is not case sensitive, but you used the 'r' switch, which makes the search a regular expression, and regular expression are by default case sensitive.
Either don't use a regular expression, of if you need to use a regular expression, use the /i modifier, which makes it case insensitive


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2016
Posts: 2
L
LiozH Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
L
Joined: Feb 2016
Posts: 2
Where in the code would you exactly place the /i modifier?

What I'm trying to do is search a string, thats saved in a variable, in a text file while keeping it case insensitive and return the whole line that the term was found at.

Joined: Jul 2006
Posts: 4,211
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,211
If $2- is from the on text event, then it is likely not a regular expression, it looks like you don't know about regular expression, in this case you should not be using it, you should not be using the 'r' switch in $read.
So forget about this /i modifier and simply use $read(catalog.txt,n,$2-)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2006
Posts: 4,211
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,211
Sorry, use $read(catalog.txt,wn,$2-)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard