Jason,
I've got a set of CFs I use for this purpose. One is the general
"NumberFormat" function which does all of the various formatting
options. I then create a second one which calls number format, and
sets all the options I want. So I've got a "CurrencyFormat" and a
"PercentFormat", but you could do any combination of the above.
Number format has the following parameters :
NumberFormat ( Integer ; Fraction ; Pretext ; ThousandChar ;
ThouPlaces ; DecimalPoint ; DecimalPlaces ; PostText )
So you can see it has all of the details you'd ever need in deciding
how to format it, but also being that detailed it makes sense to
abstract out some of the detail in a separate CF :
CurrencyFormat_US ( Number )
All of the functions I've listed below.
Cheers,
Nick
On 03/04/2007, at 6:31 AM, Jason L. DeLooze wrote:
Beverly,
I guess one could write a custom function which works essentially
like the "Number Format" options for a number type field on a
layout; I think that is essentially what you want.
Shouldn't be too hard to create; perhaps someone already has done
so and placed it in one of the custom function repositories.
Regards,
Jason L. DeLooze
Annapolis, MD USA
On 4/2/07 at 4:08 PM -0400, Beverly Voth wrote:
I'd take the "$" out altogether and let the user supply in the calc:
"$" & FormatPrecision( number; precision )
that way the function is usable for more than just USD.
Beverly
StringRepeat ( Text ; Num )
--
Case ( Num > 0 ; Text & StringRepeat ( Text ; Num - 1 ) )
---
NumberFormat ( Integer ; Fraction ; Pretext ; ThousandChar ;
ThouPlaces ; DecimalPoint ; DecimalPlaces ; PostText )
---
Let ( [
L = Length ( Integer ) ;
M = Mod ( L ; ThouPlaces ) ;
M = Case ( M = 0 ; ThouPlaces ; M ) ;
R = L - M ;
D = Case ( DecimalPlaces > 0 ; DecimalPoint ) & Left ( Fraction &
StringRepeat ( "0" ; DecimalPlaces ) ; DecimalPlaces )
] ;
Pretext &
Case (
L = 0 ; "0" & D & PostText ;
L ≤ 3 ; Integer & D & PostText ;
Left ( Integer ; M ) & ThousandChar & NumberFormat ( Right
( Integer ; R ) ; Fraction ; "" ; ThousandChar ; ThouPlaces ;
DecimalPoint ; DecimalPlaces ; PostText )
))
---
CurrencyFormat_AU ( Number )
---
Let ( [
Integer = Abs ( Int ( Number ) ) ;
Fraction = Filter ( Abs ( Number ) - Integer ; "0123456789" )
] ;
NumberFormat ( Integer ; Fraction ; Case ( Number < 0 ; "-" ) & "$" ;
"," ; 3 ; "." ; 2 ; "" )
)
---
PercentFormat ( Number ; DecimalPlaces )
---
Let ( [
Integer = Abs ( Int ( Number * 100 ) ) ;
Fraction = Filter ( Abs ( Number * 100 ) - Integer ; "0123456789" )
] ;
NumberFormat ( Integer ; Fraction ; Case ( Number < 0 ; "-" ) ; "," ;
3 ; "." ; DecimalPlaces ; "%" )
)