Page 1 of 1

Currency display in a field

Posted: Wed Sep 19, 2007 3:08 am
by petero
How do you get a field to display its contents in currency format (i.e. with $ sign and commas)?

Thank you for your help.

Peter

Posted: Sat Sep 22, 2007 8:00 pm
by Mark Smith
Peter, there isn't a built in property of fields to do this.

You have the choice of a handler in the field script, or a function in your stack or a library.

The first might be, in the field's script:

Code: Select all

on setCurrencyText pAmount
  put "$" & format("%1.2f", pAmount) into me
end setCurrencyText
so then, instead of

Code: Select all

put 20.4 into fld "someField"
you could

Code: Select all

send "setCurrencyText 20.4" to fld "someField"

Or, (and I prefer this idea) have a function like the one above that you call when putting a number into the field:

Code: Select all

put makeCurrency(20.4) into fld "someField"

Hope this helps,

Mark