mIRC Home    About    Download    Register    News    Help

Print Thread
#79119 13/04/04 12:47 PM
Joined: Oct 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Oct 2003
Posts: 9
The script turnes 10000 to 10,000

Personally I think it's useful, and hope it'll appear in the next version.

addpsik {
if ($1 == $null) { halt }
if ($1 isnum) {
if ($len($1) <= 3) { return $1 }
else {
unset %tempfinish
set %temp $1
while ($len(%temp) > 3) {
set %tempfinish $right(%temp,3) $+ , $+ %tempfinish
set %temp $left(%temp,$calc($len(%temp) - 3))
}
set %tempfinish %temp $+ , $+ %tempfinish
set %tempfinish $left(%tempfinish,$calc($len(%tempfinish) - 1))
return %tempfinish
}
}
}

#79120 13/04/04 01:30 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
You can use $bytes(number, b) to do this already (although admittedly it's not it's intended purpose). For example:
//echo -a $bytes(10000, b) echoes 10,000


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#79121 13/04/04 04:12 PM
Joined: Oct 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Oct 2003
Posts: 9
Always nice to learn about new commands, thanks!

Didn't know it exists when I searched for it, so had to build one for myself.

#79122 13/04/04 10:25 PM
Joined: Mar 2003
Posts: 187
S
Vogon poet
Offline
Vogon poet
S
Joined: Mar 2003
Posts: 187
i personally lik the key next to the 'm' key crazy

#79123 14/04/04 03:20 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
new? $bytes has been around for ages smile


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#79124 14/04/04 04:04 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
I think he meant it's new to him


New username: hixxy
#79125 15/04/04 10:39 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

that $bytes suggestion by starbucks is good, though it has problems when using decimals or negative numbers.
For example: $bytes(0.4,b) will return 0, or $bytes(5.8,b) will return 6, or $bytes(-100,b) returns -,100

This alias will cover any number, whether it is decimal, negative, or near zero:

Code:

alias commas { 
  var %min = $iif($left($1,1) == -,-)
  tokenize 46 $abs($1) 
  return $+(%min,$bytes($1,b),$iif($2,.),$2))
}

Usage: $commas(number)

Grtz


Gone.

Link Copied to Clipboard