Set Variable to Calculation Not Working

Hi!

I am following the instructions in the Wiki to set a variable to calculation but not sure why is not working and the action cancels my macro:

image

Does anyone knows what I am doing wrong? I defined my instanceGrossSales variable in a previous step, and used for other action so that's not the issue.

image

Thank you so much!

Make sure "Notify on Failure" is turned on for that action -- does the message in the notification give you any clues?

And try popping a "Display Text: instanceGrossSales" action in after the "Execute JavaScript..." one to check that you are getting a number rather than something that's being treated as text.

2 Likes

When I'm troubleshooting I always use Display Text in a window actions wherever appropriate, so I get persistent info/error messages that are easily edited.

When something cancels a macro it's frequently a good idea to consult the Keyboard Maestro Engine log.

~/Library/Logs/Keyboard Maestro/Engine.log

See my macro here:

Open the Keyboard Maestro Engine Log in the Console or BBEdit

** BBEdit is commercial software, but it reverts to a freeware "lite" version after a demo period. Even the lite version is very powerful – it has PCRE RegEx search and replace, is highly AppleScriptable, and has many other useful features. Commercial vs Freeware Comparison Chart.

1 Like

I realized what was happening so I am giving an update in case is helpful for somebody else.

So basically, the text copied from the website had a ($) and a (,) for the thousands, that was giving me an error when trying to perform the calculation.

So what I did to solve this issue is: "Search and Replace" to delete the ($) and (,) and the calculation action worked!

Hey Yisbel,

Thanks for reporting back.

Cases like this prove unequivocally why it's necessary to provide real-world data samples when asking for help.

This problem would have been solved the day you posted if we'd been able to visualize the data.

-Chris

1 Like