|
Joined: Jan 2003
Posts: 39
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2003
Posts: 39 |
hello, Im looking for an alias that will act kind of like $replace($2,dog,cat,right,left...) but will read from a text file, so i dont have a $replace a mile long
Example of text file: reads replace
dog cat right left up down
Can anyone help me? Thanks
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
Presuming that your text file is called replace.txt and that it's in your mIRC directory, give this a try. alias replace.word {
var %a = 1
while %a <= $0 {
var %word1 = $gettok($1-,%a,32)
var %word2 = $iif($read(replace.txt,s,%word1),$v1,%word1))
var %line = $replacex($1-,%word1,%word2)
inc %a
}
$iif($isid,return,echo -a) %line
}
Usage: /replace.word <sentence> or $replace.word(<sentence>) The first usage will return the information as an echoed line in your active window. The second usage will return the information to the calling script. Change filename if necessary
|
|
|
|
Joined: Jan 2003
Posts: 39
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2003
Posts: 39 |
awesome  Thanks a lot, works great.
|
|
|
|
Joined: Jan 2003
Posts: 39
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2003
Posts: 39 |
Is there a way to use * in the list for partial matches?
Thanks
|
|
|
|
Joined: Aug 2004
Posts: 7,168
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,168 |
Yes, replace var %word2 = $iif($read(replace.txt,s,%word1),$v1,%word1)) with one of the following 1) Word must end with the item being searched (ie: searching for op would also catch stop) var %word2 = $iif($read(replace.txt,w,$+(*,%word1)),$v1,%word1)) 2) Word must start with the item being searched (ie: searching for op would also catch ops) var %word2 = $iif($read(replace.txt,w,$+(%word1,*)),$v1,%word1)) 3) Word can occur anywhere (ie: searching for op would also catch stops) var %word2 = $iif($read(replace.txt,w,$+(*,%word1,*)),$v1,%word1)) NOTE: These will replace the ENTIRE word, not just the portion of the word that matches
|
|
|
|
Joined: Jan 2003
Posts: 39
Ameglian cow
|
OP
Ameglian cow
Joined: Jan 2003
Posts: 39 |
cool. Thanks again. I will give them a try.
|
|
|
|
|