mIRC Homepage
Posted By: BORR on input - 18/08/03 01:10 AM
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? confused
Posted By: MrPeepers Re: on input - 18/08/03 01:16 AM
I use this personaly
on 1:INPUT:*: {
if ( $1- == np ) { msg $active No problem | halt }
elseif ( $1- == ty ) { msg $active Thank You | halt }
:end
}
Posted By: ScatMan Re: on input - 18/08/03 01:18 AM
ON *:INPUT:*: {
if (/* !iswm $1) {
var %x
.echo -q $regsub($1-,/(^| ) $+ $gettok(%shortlist,1,46) $+ ($| )/g,$gettok(%wholelist,1,46),%x)
msg $target %x
}
}

Posted By: ScatMan Re: on input - 18/08/03 01:22 AM
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
}
}

Posted By: lammkott Re: on input - 18/08/03 01:24 AM
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.
---
Code:
if ($istok($1-,ty,32)) { var %text = $reptok($1-,ty,Thank You,32) }
.msg $active %text
Posted By: Collective Re: on input - 18/08/03 01:24 AM
Here is a slightly modified bit of code that Hammer posted earlier, you should be able to modify it to do what you want.
Code:
on *:INPUT:#:{
  if ( /* !iswm $1 ) &amp;&amp; ( $left($1,1) != $readini($mircini,text,commandchar) ) &amp;&amp; ( !$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
  }
}
Posted By: DeadlySin Re: on input - 18/08/03 01:46 AM
mrpeepers u sure that rite code coz it dont work for me laugh :tongue:
Posted By: DeadlySin Re: on input - 18/08/03 01:48 AM
:tongue: opps soz it dose work for me i got it corupted with a never 1 :tongue:

Sorry smile
Posted By: KingTomato Re: on input - 18/08/03 02:10 AM
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"
}
Posted By: MrPeepers Re: on input - 21/08/03 12:15 PM
* /while: '' unknown operator (line 6, acro.mrc)
I tried to use that script you listed and I get this any ideas?
Posted By: KingTomato Re: on input - 25/08/03 03:10 AM
btw, change %gettok to $gettok ... Srry laugh Here is new code:

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 = [&lt;acronym&gt;] | ; 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, &lt;acronym&gt;, $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
  }
}

© mIRC Discussion Forums