Money Script

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

Mark Wieder's script, adjusted to optionally support an arbitrary currency

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
  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

More information about the Use-livecode mailing list