mIRC Home    About    Download    Register    News    Help

Print Thread
#253475 16/06/15 02:24 PM
Joined: Aug 2012
Posts: 59
Maelish Offline OP
Babel fish
OP Offline
Babel fish
Joined: Aug 2012
Posts: 59
I seem to have a misunderstanding on how variable work. Assume these are global.

If I have this example in variables:
Code:
%var test
%var test2


Only the first variable will be used, correct?


What about this example? Is this treated like an array of possible results?
Code:
%var test, test2


If I try this bit of script...
Code:
on *:TEXT:%var:#channel:{ do something } 


How would I look at multiple rows of variables or an array? Thanks for your help.


Find Gamers, my player finder for tabletop RPGers and Wargamers.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You cannot perform logic in the matchtext field of an event like that, you can either match all text * and handle conditions inside the event or use a regex for the text match. There are no arrays, everything is stored as a string. You can use the token identifiers $addtok, $gettok, etc. to work with lists.

If your goal is to catch when one of multiple words are used you can use a regex match:

Code:
on $*:text:/word1|word2|word3/iS:#:{


If you're going to have a lot of these conditions it may be best to use a hash table and $hfind

Joined: Aug 2012
Posts: 59
Maelish Offline OP
Babel fish
OP Offline
Babel fish
Joined: Aug 2012
Posts: 59
Ah, this was a grand misunderstanding on my part. However you did give me the clues to fix it. Thanks! cool

This works fine:
Code:
on $*:TEXT:%var1:%var2:{...}

Where:
Code:
%var1 /word1|word2|word3/iS
%var2 /#channel1|#channel2/iS


Find Gamers, my player finder for tabletop RPGers and Wargamers.
Joined: Aug 2012
Posts: 59
Maelish Offline OP
Babel fish
OP Offline
Babel fish
Joined: Aug 2012
Posts: 59
By the way...
Originally Posted By: Loki12583
Code:
on $*:text:/word1|word2|word3/iS:#:{


What and where is /iS located in the documentation? I cannot find reference to, likely because I'm looking in the wrong place.


Find Gamers, my player finder for tabletop RPGers and Wargamers.
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Those are regex modifiers. i means case-insensitive. S is a specific flag for mIRC and means text stripped of colors, bold, etc

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
mIRC doesn't document regular expression because it's not part of mIRC and it's already documented.
Only 'S' is a special modifier, which is documented under the '$' prefix event, /help Event Prefixes


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2012
Posts: 59
Maelish Offline OP
Babel fish
OP Offline
Babel fish
Joined: Aug 2012
Posts: 59
Good responses. Thanks guys.


Find Gamers, my player finder for tabletop RPGers and Wargamers.

Link Copied to Clipboard