![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a calculated text field which is part of an invoice printout. The definition is as follows: Case ( WeeklyRental > 0 ; "Includes " & Weeks & " weeks rental. After " & Weeks & " weeks rental will be charged at £" & Round (WeeklyRental;2 ) & " per week"; "" ) This shows in an invoice to specify rental amounts after a certain number of weeks. I want this statement to completely disappear in other invoices where no rental is to be charged. |
|
As it is it works fine except - the weekly rental does not format properly as currency. So for example £30.20 comes out as £30.2. Is there any simple way to make this format properly as currency? |
|
The rental is a percentage and can have more that 2 decimal places. |
#3
| |||
| |||
|
|
And If you don't have FM7 at all you can do it equivalently without let, its just a little less readable: If ( WeeklyRental > 0 ; "Includes " & Weeks & " weeks rental. " & "After " & Weeks & " weeks rental will be charged at £" & left( Round(WeeklyRental;2)+0.005, length(Round(WeeklyRental;2)+0.005)-1) & " per week"; "") |
(
#4
| |||
| |||
|
|
else seems stuck on using 'Case' all the time. Poor old 'If' will become a nostalgic memory soon. (Anyway, there's two problems with your solution which may or may not bother the original person: A. Negative numbers get rounded towards zero rather then the correct way. eg. -9.9965 becomes -9.99 instead of -10.00 In fact, "-0.9" does somthing funny and displays as "-.89" (probably because it's adding 0.005 rather than subtracting for negative numbers). B. Numbers between 1 and 0 won't display the leading 0. eg. 0.9865 displays as .99 We did go through something similar to this a little while back for displaying numbers in scientific format (eg. 1.95E+04) and came to the conclusion that it's not as easy as it looks to round and format numbers within a calculation. We did come up with a couple of different formulas that appeared to work, but were very complicated. Helpful Harry Hopefully helping harassed humans happily handle handiwork hardships ;o) ======= |
#5
| ||||
| ||||
|
|
In article <MPG.1d3a53757cf20aac989bdf (AT) shawnews (DOT) vf.shawcable.net>, 42 nospam (AT) nospam (DOT) com> wrote: And If you don't have FM7 at all you can do it equivalently without let, its just a little less readable: If ( WeeklyRental > 0 ; "Includes " & Weeks & " weeks rental. " & "After " & Weeks & " weeks rental will be charged at £" & left( Round(WeeklyRental;2)+0.005, length(Round(WeeklyRental;2)+0.005)-1) & " per week"; "") WOW!! There IS another person on the planet who uses the 'If' statement when there's only one or two possible result ... everyone else seems stuck on using 'Case' all the time. Poor old 'If' will become a nostalgic memory soon. ( |
|
Anyway, there's two problems with your solution which may or may not bother the original person: A. Negative numbers get rounded towards zero rather then the correct way. eg. -9.9965 becomes -9.99 instead of -10.00 In fact, "-0.9" does somthing funny and displays as "-.89" (probably because it's adding 0.005 rather than subtracting for negative numbers). |

|
B. Numbers between 1 and 0 won't display the leading 0. eg. 0.9865 displays as .99 |
|
We did go through something similar to this a little while back for displaying numbers in scientific format (eg. 1.95E+04) and came to the conclusion that it's not as easy as it looks to round and format numbers within a calculation. We did come up with a couple of different formulas that appeared to work, but were very complicated. |
#6
| |||
| |||
|
|
On Sun, 10 Jul 2005 18:14:09 GMT, 42 wrote: WOW!! There IS another person on the planet who uses the 'If' statement when there's only one or two possible result ... everyone else seems stuck on using 'Case' all the time. Poor old 'If' will become a nostalgic memory soon. (It is essentially a shortcut for case. And with FM syntax its only a shortcut by two characters. But still when reading someone elses code if tells me there is only one case to look at, while case doesn't. Case is always ok and extendable. I mainly prefer 'if' whenever there's no else: if ( a=b, c) Otherwise, the case lines up better - and there's "always" yet another case to be verified ;-) case( a=b, c, d=e, f, g) |
#7
| |||
| |||
|
|
In article <slrndd7jh5.pdp.t-use (AT) ID-685 (DOT) user.individual.de>, t- use (AT) gmx (DOT) net says... I mainly prefer 'if' whenever there's no else: if ( a=b, c) Otherwise, the case lines up better - and there's "always" yet another case to be verified ;-) case( a=b, c, d=e, f, g) How does the case line up better? |
#8
| |||
| |||
|
|
WOW!! There IS another person on the planet who uses the 'If' statement when there's only one or two possible result ... everyone else seems stuck on using 'Case' all the time. Poor old 'If' will become a nostalgic memory soon. (It is essentially a shortcut for case. And with FM syntax its only a shortcut by two characters. But still when reading someone elses code if tells me there is only one case to look at, while case doesn't. |
)
#9
| |||
| |||
|
|
On Tue, 12 Jul 2005 11:48:45 -0700, Howard Schlossberg wrote: Also because If() requires two (and only two) results. With Case(), I can say: Case(A, B) and I find it to be cleaner and easier to read then If(A, B, "") Did you ever try If(A, B)!? |
#10
| |||
| |||
|
|
In article <slrndd9lk6.pth.t-use (AT) ID-685 (DOT) user.individual.de>, Martin Trautmann <t-use (AT) gmx (DOT) net> wrote: On Tue, 12 Jul 2005 11:48:45 -0700, Howard Schlossberg wrote: Also because If() requires two (and only two) results. With Case(), I can say: Case(A, B) and I find it to be cleaner and easier to read then If(A, B, "") Did you ever try If(A, B)!? That won't work in older versions of FileMaker Pro, but I'm not sure which version added the ability to not use the "else" / "otherwise" part of the If statement. I've just tried it in a FileMaker 5.5 Calculation field and you get the "two few separators" error. 'If' I get to the Mac with FileMaker 6 later today, 'then' I might try it on that version, 'otherwise' I won't. ;o) |
![]() |
| Thread Tools | |
| Display Modes | |
| |