mIRC Home    About    Download    Register    News    Help

Print Thread
#113505 05/03/05 10:33 PM
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
i need to replace some parts of a string but maintain the rest.

i use the alias $alias(number, string)
in the string i would like to have %number%
so when i call this alias it calculates the percentage inside these 2 %'s
with the number ($1)
but i would like to say as many %number% as i please and have any other text in the string that wont be effected.

any idea

thanks alot
^_^

#113506 05/03/05 11:57 PM
Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
Usage: $reppercent(N,string)

Code:
alias reppercent {
  var %a = $$2
  while $regex(perc,%a,/(%(\d+)%)/) {
    %a = $replace(%a,$regml(perc,1),$calc(($regml(perc,2) /100)* $1))
  }
  return %a 
}

Greets

#113507 06/03/05 09:46 AM
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
haha ^_^
thanks alot
wink

#113508 06/03/05 10:12 AM
Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
Np grin


Link Copied to Clipboard