mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
Hey im new in here i got a prob with this code can someone help me to fixup the problem.

here is the code:
alias co {
var %coo = 11,1
var %coo1 = 15,1
var %coo2 = 10,1
var %i = 1
while (%i <= $gettok($1,0,32)) {
if $len($gettok($1,%i,32)) != 0) {
set %co1 $left($gettok($1,%i,32),1)
set %co2 $mid($gettok($1,%i,32),2,-1)
set %co3 $right($gettok($1,%i,32),1)
var %x = %x $+ %coo %co1 $+ %coo1 $+ %co2 $+ %coo2 $+ %co3
}
inc %i
}
return %x
}

thing is its when i type $co(h) i mean single character it comes twice like "hh" and there is another problem i when i use numeric character like $co(20$ only) it comes like "2$ only", cant even use $co(2morrow) or other numeric character in the front and at the end.Can someone fixup the problem for me i tried my self but cant fix it up. Someone please help me to fix it up thankS.

Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Cleaned up your code a bit.

The if statement you had was unnecessary so I removed it. It was basically the same as your while statement. If $gettok(text,0,32) results as 5 tokens, then there are 5 tokens. It's not possible any of them can be null (0 length).

As for numbers, it's best to use double digit colors when using a background (See my post here)

I also removed your 'sets' as I don't see any reason to use them since they're only used once on each iteration.

I added an if-else to check if the length of the current token is 1, and if so use 11 as the color, else use multi-colors.

Code:
alias co {
  var %i = 1, %coo = 11,01, %coo1 = 15,01, %coo2 = 10,01, %ct, %x
  while %i &lt;= $numtok($1-,32) {
    %ct = $gettok($1-,%i,32)
    if ($len(%ct) == 1) %x = $+(%x,$chr(32),%coo,%ct)
    else %x = $+(%x,$chr(32),%coo,$left(%ct,1),%coo1,$mid(%ct,2,-1),%coo2,$right(%ct,1))
    inc %i
  }
  return %x
}

Joined: Oct 2005
Posts: 34
S
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Oct 2005
Posts: 34
thanks man u solve ma problem smile this will work


Link Copied to Clipboard