This also handles negative values...
Mark Wieder's script, adjusted to optionally support an arbitrary currency
sign...
on mouseUp
put fNumericToMoney (fld "Value",fld "Sign") into fld "currency"
end mouseUp
function fNumericToMoney pNumeric,pSign
local tMoney
local x
-- leading dollar sign and two digits for cents
if pSign="" then put "$" into pSign
put pNumeric<0 into isNeg
put abs(pNumeric) into pNumeric
put format(pSign&"%.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
end repeat
if isNeg then put "-" before tMoney
return tMoney
end fNumericToMoney
Hugh Senior
FLCo
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode