Programing style

Mark Wieder mwieder at
Fri Nov 17 11:38:37 EST 2006


Thursday, November 16, 2006, 8:54:11 PM, you wrote:

>> FUNCTION fNumericToMoney pNumeric
>>     local tMoney
>>     local x
>>     -- leading dollar sign and two digits for cents
>>     put format("$%.2f", pNumeric) into tMoney
>>     -- add the commas as necessary
>>     -- 4 is to ensure we don't get a comma before the dollar sign
>>     -- 6 here is skipping over the first three digits, the period, and the
>> cents
>>     REPEAT with x=length(tMoney)-6 to 4 step -3
>>         -- +1 to skip over the dollar sign
>>         put comma before char x+1 of tMoney
>>     return tMoney
>> END fNumericToMoney

> Nicely done, Mark! Hadn't thought of doing it that way...

Well, I hate to have magic numbers in my code, but I couldn't figure
out a way around it. Making them constants only added to the clutter.
This would be so much easier if the C standard had a currency
formatting char in printf().

...and is there a standard for how negative currency values are

-Mark Wieder
 mwieder at

More information about the Use-livecode mailing list