Number Formatting
Posted: Tue Feb 22, 2011 2:40 am
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"?
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
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