acronyms/word replacer

By Ghost-lit Warder on Sep 20, 2007

Simple script that utilizes a text file as it's database for your acronyms. Simple to use, easy to configure, and you have the option to turn it on or off. The commands are /addacro (input) (output) and /remacro (input), if you need to disable the snippet: right-click the channel and select the option. ;)

*** I must warn users that this might have difficulties with other input events. I have received none so far, but in any case please notify me asap and I will get to your issue.

#acronyms.group On

on *:input:*:{ 
  var %z = 1, %a = acronyms.txt
  if ($left($1-,1) !iswm /) && ($active !iswm Status window) {
    while (%z <= $lines(%a)) { 
      var %i = $read(%a,%z)
      if ($istok($strip($1-),$gettok(%i,1,32),32)) var %u = $replace($1-,$gettok(%i,1,32),$gettok(%i,2-,32))  
      inc %z
    }
    msg $active $iif(%u,%u,$1-) | haltdef
  }
}

#acronyms.group End

menu channel { 
  acronyms:
  .status is $iif($group(#acronyms.group).status = on, On, Off):
  ..enable:enable #acronyms.group
  ..disable:disable #acronyms.group
}

alias addacro { 
  if ($1-2) { 
   if (!$read(acronyms.txt,s,$1)) { write acronyms.txt $1 $2- } 
   else { echo $color(info) -a * error * acroynm exists in text file }
  }
}
alias remacro { 
  if ($1) { 
   if ($read(acronyms.txt,s,$1)) { write -dl acronyms.txt $1 }
   else { echo $color(info) -a * error * acronym does not exist in text file }
  }
}

Comments

Sign in to comment.
Ghost-lit Warder   -  Sep 21, 2007

Fixed.

 Respond  
guest598594   -  Sep 21, 2007

yea and shuoldnt

var %i = $read(%z,%a)

be

var %i = $read(%a,%z)
 Respond  
token   -  Sep 21, 2007

why is it inc %tmp? it should be inc %z

 Respond  
Gummo   -  Sep 21, 2007

You should check if $1 and $2 exist first.

if ($2) {
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.