mIRC Home    About    Download    Register    News    Help

Print Thread
#42636 18/08/03 01:10 AM
Joined: Mar 2003
Posts: 41
B
BORR Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Mar 2003
Posts: 41
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

#42637 18/08/03 01:16 AM
Joined: Aug 2003
Posts: 136
Vogon poet
Offline
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
}


In Virginia, chickens cannot lay eggs before 8:00 a.m., and must be done before 4:00 p.m.
#42638 18/08/03 01:18 AM
Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
ON *:INPUT:*: {
if (/* !iswm $1) {
var %x
.echo -q $regsub($1-,/(^| ) $+ $gettok(%shortlist,1,46) $+ ($| )/g,$gettok(%wholelist,1,46),%x)
msg $target %x
}
}


#42639 18/08/03 01:22 AM
Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
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.
#42640 18/08/03 01:24 AM
Joined: May 2003
Posts: 215
Fjord artisan
Offline
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.
---
Code:
if ($istok($1-,ty,32)) { var %text = $reptok($1-,ty,Thank You,32) }
.msg $active %text


- Jason
#42641 18/08/03 01:24 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
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
  }
}

#42642 18/08/03 01:46 AM
Joined: Aug 2003
Posts: 73
D
Babel fish
Offline
Babel fish
D
Joined: Aug 2003
Posts: 73
mrpeepers u sure that rite code coz it dont work for me laugh :tongue:


IRC (Idiots Relay Chat) :tongue:

{]TDN[}Deadly-Sin
#42643 18/08/03 01:48 AM
Joined: Aug 2003
Posts: 73
D
Babel fish
Offline
Babel fish
D
Joined: Aug 2003
Posts: 73
:tongue: opps soz it dose work for me i got it corupted with a never 1 :tongue:

Sorry smile


IRC (Idiots Relay Chat) :tongue:

{]TDN[}Deadly-Sin
#42644 18/08/03 02:10 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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"
}


-KingTomato
#42645 21/08/03 12:15 PM
Joined: Aug 2003
Posts: 136
Vogon poet
Offline
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?


In Virginia, chickens cannot lay eggs before 8:00 a.m., and must be done before 4:00 p.m.
#42646 25/08/03 03:10 AM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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
  }
}



-KingTomato

Link Copied to Clipboard