mIRC Home    About    Download    Register    News    Help

Print Thread
#41174 11/08/03 09:27 PM
Joined: Aug 2003
Posts: 2
V
vipez Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
V
Joined: Aug 2003
Posts: 2
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 ?

#41175 11/08/03 10:05 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
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


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard