On the other hand, you can just use data formatting in the inspector to set up currency formatting--including a fixed number of decimal points for this field when you put it on a layout. This changes how the value is displayed, but does not change the actual value.
I agree with Menno van Beek that the referenced function is a good solution.
To answer your original question about calculating the number of digits past the decimal in a number that you have already converted to text ...
Length(GetValue( Substitute(numberAsText; "."; "¶"); 2))
Thanks, Phil. The field is already set up as currency with two decimal places in the fields on my layouts. The zeros are dropped in the calculation that includes text statements. I think there should be a easy way to resolve without going to the long custom function Menno suggests. Here is the field I am using my statements to donors:
"Your Last Donation: " & If ( IsEmpty ( zc_AmountLastDonation ) ; "New Donor." ; zc_DateLastDonation & ", $ " & zc_AmountLastDonation & ".") & "¶" & If ( not IsEmpty ( zc_Sum_Donations_2016 ) ; "Total 2016 Donations: $ " & zc_Sum_Donations_2016 & ". ";"") & "Thank You."
Thanks, Tom. I will give your suggestion a try. Wow, already three replies to my question. If I can ask good questions, I no longer have an excuse in feeling isolated and on my own limited resources!
Thanks, Menno. Two others support your solution, so I will have to get out the book on setting up Custom Functions. I do have advanced, but don't use its capabilities nearly enough.
There are many ways to solve this type of problem and using a custom function makes the solution much tidier.
If you want to work the problem on your own and play with different possible calculations, here is an alternate method that is less sophisticated than the one by Agnès.
This takes as its input OriginalAmount which is a number.
num = Round ( OriginalAmount; 2 ) ;
dollars = Int(num);
cents = (num - dollars) * 100
dollars & "." & Right("00" & cents; 2)
And the block of text that contains a merge field can be given currency formatting.
Thanks to all for so many generous, wise responses. I am encouraged to work harder to expand my FMP professionalism! I will try a Merge Field solution. Cheers. Bill M