mIRC Home    About    Download    Register    News    Help

Print Thread
#226319 26/09/10 11:04 PM
H
Harry_
Harry_
H
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-
    } 
  }
}  

#226324 26/09/10 11:41 PM
Joined: Nov 2006
Posts: 1,552
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,552
- 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-
}

#226326 26/09/10 11:55 PM
Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
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.

Tomao #226327 26/09/10 11:58 PM
Joined: Nov 2006
Posts: 1,552
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,552
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?

Horstl #226328 27/09/10 12:11 AM
H
Harry_
Harry_
H
Ok thanks so much works perfect

Horstl #226339 27/09/10 08:32 PM
H
Harry_
Harry_
H
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

#226349 28/09/10 11:13 AM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
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.


Link Copied to Clipboard