Calculations

Hello, I’m new to KM and have already built a macro that opens Safari, introduces login credentials from
1Password, logins to my bank statement and copies the number representing total cash available. Then, macro
opens another Safari web page and logins to my Cloud Accounting, invokes Balance and copies the total cash available from Balance. Both values are stored in variables. Now, I can’t make Calculations work correctly to substract one another, to display a message of either “Balance squares off to Bank statement” or not.
Can you please give me very simple examples on how to perform calculations with variables, and clipboard…?
Thank you in advance for your kind help

Read this wiki page on Text Fields because it will probably help.

Use the Set Variable to Calculation action, or If Then Else action with the Calculation condition.

Thank you so much for kind and prompt response.
The number copied from bank website is, for example, 3,280.75. I’ m setting the variable to Text, and not to Calculation as suggested, because the latter will not store the %CurrentClipboard% content ( since the macro copies the “value” from what is displayed on bank website. Furthermore, naturally, the program does not interpret it as a number but as a string.
How can I from a copied string (3,280.75) make KM realize it is a number we need to store for later use in calculations?
Thanks again, excellent KM both app and support.
Regards

Keyboard Maestro only has string variables, but if they hole numbers they can be used in calculations.

“3,280.75” is actually an array of numbers, “3” and “280.75” as far as Keyboard Maestro is concerned. So you need to remove the commas.

Use the Search and Replace Variable action to search for “,” and replace with “”.

I did, yet I still get the comma....

Try searching for just the comma, no quotation marks, leave the replace field completely blank, and then it should work.

The first action is setting the clipboard, not the Cash in Balance variable. It should be:

The Search & Replace, remove the quotes.

Thank you so much both of you gentlemen…
It worked nicely, I’ll build upon what I have learned so far. Will recommend immensely KM to all Mac users I know
Thanks again for unbelievable support and a great product!

2 Likes