Number Formatting
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Number Formatting
I have a variable "score" that holds the users score value. This number can often reach more than 1 million. Is there any way to format it like "11,000,000" instead of "11000000"?
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Number Formatting
hi...
Look at the attached stack... it might help
be well
Dixie
Look at the attached stack... it might help
be well
Dixie
- Attachments
-
- commaNumbers.rev.zip
- (1.27 KiB) Downloaded 268 times
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Number Formatting
hi...
or in a function...
I should have posted that first...
Dixie
or in a function...
Code: Select all
on mouseUp
put commaNumber(fld 1) into fld 1
end mouseUp
function commaNumber theString
put the number of chars of theString into charCount
if charCount < 3 then exit commaNumber
put 0 into commaCount
repeat with count = charCount down to 1
if commaCount = 3 then
put comma before commaNumbers
put 0 into commaCount
end if
put char count of theString before commaNumbers
add 1 to commaCount
end repeat
return commaNumbers
end commaNumber
Dixie
Re: Number Formatting
Thanks that should work!