Money Script
Bob Sneidar
bobs at twft.com
Tue Aug 9 12:46:43 EDT 2011
Are you guys reading my mind?? Are you hacking into my computer at night to see what functions I need you to write and then writing them the next day??? ;-) Thanks, I am on the verge of needing exactly this!
Bob
On Aug 8, 2011, at 11:02 PM, FlexibleLearning wrote:
> 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
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list