Formatting numbers
Peter T. Evensen
pevensen at siboneylg.com
Fri Jan 13 18:46:44 EST 2006
Here is what I use, not sure if it the best, but it works for any size number:
function AddNumberSeparator pValue
local tDecimalPointPos, tLength, tSeparatorPosition
put offset(".",pValue) into tDecimalPointPos
put the number of chars in pValue into tLength
if tDecimalPointPos is not zero then put tDecimalPointPos - 1 into tLength
put tLength - 3 into tSeparatorPosition
repeat while tSeparatorPosition > 0
put char 1 to tSeparatorPosition of pValue & "," & char
tSeparatorPosition + 1 to -1 of pValue into pValue
subtract 3 from tSeparatorPosition
end repeat
return pValue
end AddNumberSeparator
At 05:40 PM 1/13/2006, you wrote:
>Does somebody have a suggestion for formatting numbers with commas for a
>printed report? It wil have columns of data, with numbers ranging from
>small to large. The larger ones are hard to read, so I'd like to insert
>commas at the appropriate places. I can think of clunky ways to do it, but
>thought I'd ask here in case someone had already brewed up something nice.
>
>Thanks,
>
>Marty Knapp
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-revolution
Peter T. Evensen
http://www.PetersRoadToHealth.com
314-629-5248 or 888-628-4588
More information about the use-livecode
mailing list