mIRC Home    About    Download    Register    News    Help

Print Thread
Understanding Variables #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.
Re: Understanding Variables [Re: Maelish] #253476 16/06/15 02:38 PM
Joined: Jan 2004
Posts: 1,330
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,330
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

Re: Understanding Variables [Re: Loki12583] #253495 16/06/15 11:31 PM
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.
Re: Understanding Variables [Re: Loki12583] #255011 14/09/15 02:13 PM
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.
Re: Understanding Variables [Re: Maelish] #255012 14/09/15 03:15 PM
Joined: Sep 2014
Posts: 259
S
Sakana Offline
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

Re: Understanding Variables [Re: Maelish] #255016 14/09/15 07:52 PM
Joined: Jul 2006
Posts: 3,829
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,829
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Understanding Variables [Re: Wims] #255065 18/09/15 01:41 PM
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.