|
BORR
|
BORR
|
I have script which turns "ty" into "Thank You": ON *:INPUT:*: { if (/* !iswm $1) { msg $active $replace($1-,$gettok(%shortlist,1,46), $gettok(%wholelist,1,46) ) } $shortlist == ty.np $wholelist == Thank You.No Problem So when I type "np" it replaces "np" with "No Problem". But now the problem: If I have "np" in a word it also replaces it and I have "No Problem" in the middle of the word... How can I fix that?
|
|
|
|
Joined: Aug 2003
Posts: 136
Vogon poet
|
Vogon poet
Joined: Aug 2003
Posts: 136 |
I use this personaly on 1:INPUT:*: { if ( $1- == np ) { msg $active No problem | halt } elseif ( $1- == ty ) { msg $active Thank You | halt } :end }
|
|
|
|
ScatMan
|
ScatMan
|
ON *:INPUT:*: { if (/* !iswm $1) { var %x .echo -q $regsub($1-,/(^| ) $+ $gettok(%shortlist,1,46) $+ ($| )/g,$gettok(%wholelist,1,46),%x) msg $target %x } }
|
|
|
|
ScatMan
|
ScatMan
|
sorry, ON *:INPUT:*: { if (/* !iswm $1) { var %x .echo -q $regsub($1-,/(?<=^| ) $+ $gettok(%shortlist,1,46) $+ (?=$| )/g,$gettok(%wholelist,1,46),%x) msg $target %x halt } }
Last edited by ScatMan; 18/08/03 01:33 AM.
|
|
|
|
Joined: May 2003
Posts: 215
Fjord artisan
|
Fjord artisan
Joined: May 2003
Posts: 215 |
Try using $istok(), $reptok() From the help file.. --- $istok(text,token,C)Returns $true if token exists, otherwise returns $false. $reptok(text,token,new,N,C)Replaces the Nth matching token in text with a new token. $reptok(a.b.c.d,b,e,1,46) returns a.e.c.d $reptok(a.b.c.d,f,e,1,46) returns a.b.c.d $reptok(a.b.a.c,a,e,2,46) returns a.b.e.c Note: $reptokcs() is the case-sensitive version. ---
if ($istok($1-,ty,32)) { var %text = $reptok($1-,ty,Thank You,32) }
.msg $active %text
|
|
|
|
Joined: Dec 2002
Posts: 3,015
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,015 |
Here is a slightly modified bit of code that Hammer posted earlier, you should be able to modify it to do what you want. on *:INPUT:#:{
if ( /* !iswm $1 ) && ( $left($1,1) != $readini($mircini,text,commandchar) ) && ( !$ctrlenter ) {
var %1- = $1-
while ($istok(%1-, np, 32)) %1- = $reptok(%1-, np, 3No problem, 1, 32)
while ($istok(%1-, ty, 32)) %1- = $reptok(%1-, ty, 3Thank you, 1, 32)
say %1-
halt
}
}
|
|
|
|
DeadlySin
|
DeadlySin
|
mrpeepers u sure that rite code coz it dont work for me  :tongue:
|
|
|
|
DeadlySin
|
DeadlySin
|
:tongue: opps soz it dose work for me i got it corupted with a never 1 :tongue: Sorry
|
|
|
|
Joined: Jan 2003
Posts: 2,973
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,973 |
I made a hash-table version of this somewhere on the forums. You may try using Search and use the keywords "hash acronym". Search all forums, with the date extended to all posts. Its much faster, and a low easier to add/rem acronyms (IMO) EDIT: https://forums.mirc.com/showflat.php?Cat=...=true#Post37286 You may even decide to make a popup menu to add acronyms like: menu * { Add Acronym: /hadd acronym $$?="Enter acronym followed by meaning $crlf Ex: lol Laughing Out Loud" }
|
|
|
|
Joined: Aug 2003
Posts: 136
Vogon poet
|
Vogon poet
Joined: Aug 2003
Posts: 136 |
* /while: '' unknown operator (line 6, acro.mrc) I tried to use that script you listed and I get this any ideas?
|
|
|
|
Joined: Jan 2003
Posts: 2,973
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,973 |
btw, change %gettok to $gettok ... Srry  Here is new code:
; initialize the first few acronyms
alias acronym.init {
; add the values to our table
/hadd acronym afk Away From Keyboard
/hadd acronym brb Be Right Back
/hadd acronym gtg Got To Go
/hadd acronym lol Laughing Out Loud
/hadd acronym ttyl Talk To You Later
}
; Intiilize the table
on *:START: {
; create the hash table of 100 items (size of 10)
/hmake acronym 10
; Load our hash file if it's there, other wise initialize the hash table
if ($isFile(acronyms.hsh)) {
; file exists, now we load it
/hload acronym acronyms.hsh
}
else {
; the file does not exist. Now we initialize, and save
/acronym.init
/hsave -o acronym acronyms.hsh
}
}
; Save the table
on *:EXIT: {
; save our table on exit
/hsave -o acronym acronyms.hsh
; clear the used memory
/hfree acronym
}
; replace acronyms with their proper meaning
on *:INPUT:#: {
; first make sure the text entered isn't a command
if ($left($1, 1) !isin $+(/,$readini($mircini, text, commandchar))) {
; search for words to replace
var %w = 1 | ; current word we're comparing
var %text | ; current message
var %acro = [<acronym>] | ; the design you want your acronym to take
; loop through each word looking through a match
while ($gettok($1-, %w, 32) != $null) { | ; we include != $null incase the user types a 0
var %word = $ifmatch
; find the word in our table
if ($hget(acronym, %word) != $null) var %text = %text $replace(%acro, <acronym>, $ifmatch)
else var %text = %text %word
; Increase Counter Variable
/inc %w
}
; send the message to the channel
/msg $chan %text
; stop the "double talk"
/halt
}
}
|
|
|
|
|