mIRC Homepage
Posted By: vipez word completor - 11/08/03 09:27 PM
I have this statement

Code:
   if (*ty* iswm $1-) { .m $active $replace($1-,ty,$wc1(T) $+ hank $wc1(Y) $+ ou)  | halt }


how can i make it react to ty type several times in the same line ? like ty ty very much should output

thank you thank you very much

I have more "wc" in the script and want them all to be able to react in the same line.. like "ty brb" should do a "thank you be right back"

you get the point ?
Posted By: Hammer Re: word completor - 11/08/03 10:05 PM
You have to rebuild your output string. I would suggest a series of while loops (extremely simple ones) that use $reptok rather than $replace since you obviously don't want "qwertyuiop" to be replaced by "qwerThank Youuiop".
Code:

  var %a = $1-
  while ($istok(%a, ty, 32))  %a = $reptok(%a,  ty, $+($wc1(T),hank $wc1(Y),ou)               , 1, 32)
  while ($istok(%a, bbl, 32)) %a = $reptok(%a, bbl, $+($wc1(B),e    $wc1(B),ack  $wc1(L),ater), 1, 32)
  while ($istok(%a, brb, 32)) %a = $reptok(%a, brb, $+($wc1(B),e    $wc1(R),ight $wc1(B),ack) , 1, 32)
  while ($istok(%a, tyt, 32)) %a = $reptok(%a, tyt, $+($wc1(T),ake  $wc1(Y),our  $wc1(T),ime) , 1, 32)
  say %a
  halt
}

Another way to do the exact same job (without loops) is to use $regsub:
Code:

  var %a = $1-
  !.echo -q $regsub(%a, / \b (ty ) ([^\w]) /gix, $+($wc1(T),hank $wc1(Y),ou)\2               , %a)
  !.echo -q $regsub(%a, / \b (bbl) ([^\w]) /gix, $+($wc1(B),e    $wc1(B),ack  $wc1(L),ater)\2, %a)
  !.echo -q $regsub(%a, / \b (brb) ([^\w]) /gix, $+($wc1(B),e    $wc1(R),ight $wc1(B),ack)\2 , %a)
  !.echo -q $regsub(%a, / \b (tyt) ([^\w]) /gix, $+($wc1(T),ake  $wc1(Y),our  $wc1(T),ime)\2 , %a)
  say %a
  halt
}

cool
© mIRC Discussion Forums