Delimiting thousandths..converting 12345678 to 12, 345, 678 for example
Brian Yennie
briany at qldlearning.com
Tue Jun 12 18:10:27 EDT 2007
If you just need something for whole integers, how about something
simple like:
function thousandsDelimit pNum
repeat with i=-1 down to (0 - length(pNum))
put char i of pNum before temp
if (i mod 3 = 0) then put comma before temp
end repeat
if (char 1 of temp is comma) then delete char 1 of temp
return temp
end thousandsDelimit
If you needed to work with decimals, you could call it with something
like:
set the itemDelimiter to "."
put thousandsDelimit(item 1 of tNum) into item 1 of tNum
HTH,
Brian
> If there a built-in "thousandths delimit" function that takes a
> number and inserts the appropriate delimiter (e.g. commas for
> USA). Alternately, does someone have an idea for a really fast and
> efficient custom function that does it? I have maybe a hundred
> thousand numbers at a time to convert and cannot think of how to do
> it reliably in less than a dozen lines of code.
>
> Corollary to this question is, any way to read user's system
> preferences about which delimiter to use?
>
> Thanks
>
> Mark
>
>
> _______________________________________________
> 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
More information about the use-livecode
mailing list