Delimiting thousandths..converting 12345678 to 12, 345, 678 for example
Jim Ault
JimAultWins at yahoo.com
Tue Jun 12 21:29:26 EDT 2007
One thing ver (1) does not handle is the switching separator.
I should have said:
if pSeparator is "," then set the itemDel to "."
--otherwise comma will be used
...then finished with...
get (holdPrefix & pNum)
put holdDec into item 2 of it
return it
----------
I will offer a slight (2) improvement to make it a bit more universal
-- neg numbers
--preceeded by $
--decimals
--handle switching separators
function formatThousands pNum,pSeparator
repeat while char 1 of pNum is not a number then
put char 1 of pNum after holdPrefix
put char 2 to -1 of pNum into pNum
end repeat
if pSeparator is "," then set the itemDel to "." -- <--better
put item 2 of pNum into holdDec
put item 1 of pNum into pNum
> repeat with x = length(pNum)-3 to 3 step -3
> put pSeparator before char x+1 of pNum
> end repeat
get (holdPrefix & pNum)
put holdDec into item 2 of it
return it
end formatThousands
On 6/12/07 6:01 PM, "Jim Ault" <JimAultWins at yahoo.com> wrote:
> Thanks for the props.
> Note: the function also handles the accounting format where the "-" sign is
> trailing since the decimal and beyond is held as a suffix.
>
> Jim Ault
> Las Vegas
>
>
> On 6/12/07 5:08 PM, "Mark Wieder" <mwieder at ahsoftware.net> wrote:
>
>> Jim-
>>
>> Nice. Very nice.
>>
>> Ken-
>>
>> Is this a candidate for inclusion in the standard library?
>
>
> _______________________________________________
> 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