Sum two values after stripping some characters

Hi guys,

I've now spent over 4 hours trying to figure this out, and I cannot :cry:

I am copying two values from a webpage (they change every week); I need to strip these values from unnecessary characters and then sum and copy them to a spreadsheet.

Example of the values copied from the webpage
2023-06-19 Screenshot 000755

The output should be without the dot and the € sign. Expected output 7844,24.

The transformation of the output seems to screw up what I am trying to do.

I am pretty sure this is such a simple thing, I am just missing some basic knowledge that I cannot figure out myself.

Thank you for any suggestions.

Rosario

Hi Rosario,
Here's a brute-force macro to address your problem:

Download Macro(s): Test Sum Two Value.kmmacros (8.9 KB)

Macro-Image

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 10.14.6
  • Keyboard Maestro v10.2

Points to note:

  1. I've hard-coded the two values in the red-coloured actions. You might want to replace these with the appropriate actions for your use-case.
  2. The macro could be shortened considerably by using a subroutine in place of the groups called "Convert Value1" and "Convert Value 2". (Ignore this comment if you don't understand what a subroutine is/does.)
  3. The result is displayed in a window (orange action at the end). Obviously change that to make use of the result in whatever way you wish.
  4. The output is 7844,29

Thank you so much @tiffle,

All I was missing was that conversion of the comma to the dot.

For my full understanding, just to ensure I get this right in the future, we are converting the comma to a dot, so that Keyboard Maestro can recognize the value correctly and execute the calculation right? The dot is the universal decimal indicator, not the comma and with a comma we would have no results.

Cheers

That’s correct - the calculation would fail if there were still commas in the value strings.

1 Like