Money Script

FlexibleLearning admin at FlexibleLearning.com
Tue Aug 9 01:49:17 EDT 2011


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 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
  return tMoney
end fNumericToMoney


Hugh Senior
FLCo





More information about the Use-livecode mailing list