CalculateFormat question

The following CalculateFormat as I understand should yield 123.00. But it yields 123. What am I doing wrong and how should I get the 123.00?

%CalculateFormat% 123 %##0.00%

Thanks!!

You are applying two calculate processes:

  • the first (that you’ve highlighted in blue) will produce 123.00
  • the second is the Calculate Filter which will produce 123

The solution is to use the Set Variable to Text action and in it put your blue-highlighted formula like this:

image

Do remember what the KM wiki says about this: "the output of this token will likely not be a valid number for a Keyboard Maestro calculation. It should be used only for display purposes."

1 Like

Hehe, that one's my fault/responsibility: Before, it wasn't very clear about the effect of adding a format, and I had a macro that was dying, but only for users who use the "0.000,00" number format. It took forever to figure out that it was due to my trying to use a formatted number in a future numeric operation. In the USA, it worked, as we use the "0,000.00" format, so the math still worked. But when it tried to do math with "123,43," for instance, it failed. I asked Peter for a more-direct note about the effect of applying a format :).

Long story short, you need to use multiple variables if you're going to work with numbers that you also need formatted for display along the way: One holds the unformatted number for use in all calculations, and anywhere you need to display it, set a local variable equal to the unformatted number at that point in time, but with formatting.

-rob.

2 Likes

Yeah, thanks for the explanation. Now I understand that remark in the Wiki. :yum: