mIRC Home    About    Download    Register    News    Help

Print Thread
Script help #226319 26/09/10 11:04 PM
Joined: Oct 2009
Posts: 3
H
Harry_ Offline OP
Self-satisified door
OP Offline
Self-satisified door
H
Joined: Oct 2009
Posts: 3
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-
    } 
  }
}  

Re: Script help [Re: Harry_] #226324 26/09/10 11:41 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
- 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-
}

Re: Script help [Re: Harry_] #226326 26/09/10 11:55 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Re: Script help [Re: Tomao] #226327 26/09/10 11:58 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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?

Re: Script help [Re: Horstl] #226328 27/09/10 12:11 AM
Joined: Oct 2009
Posts: 3
H
Harry_ Offline OP
Self-satisified door
OP Offline
Self-satisified door
H
Joined: Oct 2009
Posts: 3
Ok thanks so much works perfect

Re: Script help [Re: Horstl] #226339 27/09/10 08:32 PM
Joined: Oct 2009
Posts: 3
H
Harry_ Offline OP
Self-satisified door
OP Offline
Self-satisified door
H
Joined: Oct 2009
Posts: 3
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

Re: Script help [Re: Harry_] #226349 28/09/10 11:13 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net