cs_TropNul
Messages postés
340
Date d'inscription
dimanche 18 septembre 2005
Statut
Membre
Dernière intervention
22 octobre 2009
6 janv. 2007 à 02:02
Je ne voyais pas le problème car dans mes tests, je faisais un echo %Z à la place de return %Z. Et j'appelais l'alias ainsi: /BUB mon texte et ça fonctionnait sans problème.
Il y a un problème apparement dès qu'on appele l'alias en tant qu'identifieur. Je ne vois pas trop pourquoi d'ailleurs. donc j'ai mis un tokenize au début aussi pour qu'il considère bien tous les mots fournit. bref voila le résultat ;o)
alias b { var %l 1, %c 1, %text
while (%l <= $len($1-)) {
var %m = $mid($1-,%l,1)
if (%m != $chr(32)) { if ($calc(%c % 2) 1) { %text $+(%text,$chr(2),%m,$chr(2)) }
else { %text = %text $+ %m }
inc %c
}
else { %text = %text $+ $chr(160) }
inc %l
}
return %text
}
ALIAS BUB { VAR %W , %X , %Y , %Z , %R /(.)(.)/g , %S /(.)/g
TOKENIZE 32 $1-
WHILE $regex(GtWrd,$1-,/([^[:space:]]+)/i) {
%W = $regml(GtWrd,1) IF ($calc($len(%W) % 2) 1) { %X $regsub(%W,%S,$+($chr(2),\1,$chr(2),$chr(2)),%Y) }
ELSE { %X = $regsub(%W,%R,$+($chr(2),\1,$chr(2),\2),%Y) }
%Z = %Z $+ $chr(32) $+ %Y | TOKENIZE 32 $2-
}
RETURN %Z
}
alias regbench {
var %a 200 ,%t = $ticks
while (%a) { var %q = $BUB(GaisGaisGai sGai sGa isGa isGaisGaisGa isGaisGa) | dec %a }
echo -a Temps $!BUB : $calc($ticks - %t) ms
}
alias regbench1 {
var %a 200 ,%t = $ticks
while (%a) { var %q = $b(GaisGaisGai sGai sGa isGa isGaisGaisGa isGaisGa) | dec %a }
echo -a Temps $!b : $calc($ticks - %t) ms
}
Temps $BUB : 344 ms
Temps $b : 1844 ms
^^
TropNul