create a calculation field ( fixed format currency ):
s = If ( Sign ( YourNumber ) - 1 ; "-" ) ;
e = Sign ( YourNumber ) / 10 ^ 3 ;
n = Abs ( YourNumber + e )
Case ( n ; s & NumToJText ( Int ( n ) ; 1 ; 0 ) & Left ( Mod ( n ; 1 ) ; 3 ) ; "0.00" )
You could choose to set the result of that calculation to number or text.
Than place that field into your custom dialog.
Thanks, I get the idea. I'll play with that over the weekend.
If this is used in Custom Dialog then there is no need to create a calculation. The calculation can be specified right within the message itself. :^)
Yes, I already tried it in a Show Custom Dialog statemnt and it does what I need.
I suggest to use a calculated field because it can have other uses: for example inside a merged text or for exportation purposes.
I would not create ANY calculation unless the specific need arises; that is how field bloat happens.
We do not know where and how often it might be used; only dwf knows. I use calculations all the time that I never create as calculations. Don't clutter your field definitions until you see that there is no other choice.
If you do anything, make a custom function out of it. Then when you DO need it, it is available in scripts, merge variables or calculations when working with ANY number. :^)
For my purposes, I'll be converting three or four numbers to fixed format for currency display, so it suits me best to put it in a sub-script that I can call from Show Dialog.
Thanks to both of you for your suggestions.
raybaudi's formula is the only one i have found that also works properly with negative numbers
Hi! I came here for the exact same reason: trying to add the trailing zero. Well, I figured out a cludge, but it works. Note that I'm using FMPro 6, an ancient verison, which wouldn't even consider the programming above, but I was inspired by it. So...
Suppose your field is for previous billing charges, "Previous Charges", then:
(Previous Charges) & (If(Right((Previous Charges), 2) < "1", "0", ""))
This just takes the previous charge, and uses a Text function to test whether the two numbers to the right of the decimal point are less than 1, in which case it will add a zero. If not, it leaves it blank (at least that's how I understand it). In my case, $10.3 magically turns to $10.30, and $10 remains the same.
Hope this helps someone. I have been helped here many times before, and this is my first time being able to give back.
Addendum: The above cludge also works with odd digits, like $10.93 (i.e., leaves the 93 cents), as well as negative numbers, at least in my set-up!