mIRC Homepage
Posted By: Harry_ Script help - 26/09/10 11:04 PM
Hey guys, I have mIRC v7.1 and I'm having trouble getting this script, or any script with /window @name and /aline in it, to work.


Code:
on *:text:*:#: 
{ 
  if ($regex($1-,/\bHarry\b/i) > 0)
  { 
    if ( $window(@alerts)) 
    { 
      aline -p @alerts $timestamp -2 [ $network ] 1-2 $chan 1-10 $nick $+ 1: $1- 
    }
    else 
    { 
      window -e0 @alerts test
      aline -p @alerts $timestamp -2 [ $network ] 1-2 $chan 1-10 $nick $+ 1: $1-
    } 
  }
}  
Posted By: Horstl Re: Script help - 26/09/10 11:41 PM
- You have to place {-brackets on the same line as the event/condition
- mIRC treats isolated [ and ] chars as evaluation brackets. If you want to use the chars literally, escape them with either $chr() or $(<char>,0)

Working code:
Code:
on *:text:*:#: { 
  if ($regex($1-,/\bHarry\b/i) > 0)  { 
    if ( $window(@alerts)) { 
      aline -p @alerts $timestamp -2 $chr(91) $network $chr(93) 1-2 $chan 1-10 $nick $+ 1: $1- 
    }
    else { 
      window -e0 @alerts test
      aline -p @alerts $timestamp -2 $chr(91) $network $chr(93) 1-2 $chan 1-10 $nick $+ 1: $1-
    } 
  }
}

Suggestion (condensed code):
Code:
on $*:text:/\bHarry\b/i:#: {
  if (!$window(@alerts)) { window -e0 @alerts }
  aline -p @alerts $timestamp -2 $chr(91) $network $chr(93) 1-2 $chan 1-10 $nick $+ 1: $1-
}
Posted By: Tomao Re: Script help - 26/09/10 11:55 PM
It's wasteful to use regex for a one-word match. But if you opt for the convenience of regex, you should add the /iS modifier to it so it'll strip out control codes.
Posted By: Horstl Re: Script help - 26/09/10 11:58 PM
Well, if he's after more than "isolated" words (space-delimited tokens) but word boundaries like "Harry, hey" or "Hi harry!"... how do you suggest to match them?
Posted By: Harry_ Re: Script help - 27/09/10 12:11 AM
Ok thanks so much works perfect
Posted By: Harry_ Re: Script help - 27/09/10 08:32 PM
Originally Posted By: Horstl
Well, if he's after more than "isolated" words (space-delimited tokens) but word boundaries like "Harry, hey" or "Hi harry!"... how do you suggest to match them?


If you wouldn't mind answering that question for future reference, thanks smile
Posted By: Riamus2 Re: Script help - 28/09/10 11:13 AM
I believe he already did in his script. He was saying that use of regex is useful for that and wanted to see why Tomao thought regex was wasteful and how he'd do it without regex that would be more efficient.
© mIRC Discussion Forums