mIRC Home    About    Download    Register    News    Help

Print Thread
Highlight words using the TEXT event and $replace. #150216 30/05/06 12:32 AM
Joined: May 2006
Posts: 3
X
XavierGr Offline OP
Self-satisified door
OP Offline
Self-satisified door
X
Joined: May 2006
Posts: 3
Hello all.

Sorry if this has already answered, but I couldn't come up to something with the search function.

I want to highlight words. Not the whole line (that mIRC offers by default) but just the word that matches a specific string.

It took me some time to learn scripting basics and I've come to this:
On the remote tab:

on *:text:*:#: $replace($1-, "search string", "new string")

This though won't work on my case. It seems to work with the input event (along with some modifications) but I just want whenever I receive a message (on a channel or query) to change the received line to a highlighted word.

As long as I can replace the search string onto the incoming line then I suppose I can colorize it. (to highlight the word)

So summing up: Is my approach right? If not, is it possible to highlight a specific word (not the whole line) when I receive a channel (or query) message?

Hope this makes sense. Thanks in advance.

Re: Highlight words using the TEXT event and $repl #150217 30/05/06 01:01 AM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
you were close
try this
Code:
on ^*:text:*:#:{
  var %red = 4,8
  var %text = $replace($1-,word,%red $+ Word)
  echo -a $+(<,$nick,>) %text
  haltdef
}

Re: Highlight words using the TEXT event and $repl #150218 30/05/06 07:28 PM
Joined: May 2006
Posts: 3
X
XavierGr Offline OP
Self-satisified door
OP Offline
Self-satisified door
X
Joined: May 2006
Posts: 3
Ah thank you very much!
It is now clear to me what I must do.

Re: Highlight words using the TEXT event and $repl #150219 31/05/06 04:30 PM
Joined: May 2006
Posts: 3
X
XavierGr Offline OP
Self-satisified door
OP Offline
Self-satisified door
X
Joined: May 2006
Posts: 3
Ok I finally finished my highlight script.

What it does:
Adds 3 popup menus to control the highlighted words.
1. Add highlighted word
2. List highlighted words
3. Delete highlighted words

On every text event it will search highlight.txt and replace every match it sees.

Code:
Add to popup menu
Add Highlighted Word:{
/write highlight.txt $?="Write a word to add it to the highlight list, $crlf $+ along with the colours you want to highlight it. $crlf $crlf $+ E.x: 8,1testword")
}

List Highlighted Words:{
%k = 1
echo -a #. Word -------

while $read(highlight.txt,%k) {
echo -a $+(%k, ., $chr(32), $read(highlight.txt,%k))
inc %k
}
echo -a ---------------

}

Delete Highlighted Word:{
%k = 1
echo -a #. Word -------
while $read(highlight.txt,%k) {
echo -a $+(%k, ., $chr(32), $read(highlight.txt,%k))
inc %k
}
echo -a ---------------

%choice = $?="Write the number of the word you want to delete."
/write -dl %choice highlight.txt
}

Add to remote menu:
alias hilight {
%text = $+(<, $1, >, $chr(32), $2)

var %i = 1
while $read(highlight.txt,%i) {
%text = $replace(%text,$strip($read(highlight.txt,%i),c),$read(highlight.txt,%i))
inc %i
}
return %text
}

on ^*:text:*:#:{
echo -t $chan $hilight($nick, $1-) | halt
}


This is my first little script. I hope it will come usefull for some.
Thanks for the help again!