# Calculate Clipboard 1 and 2 to Clipboard 3

I desperatly need a macro to do the following:
I simply want to calculate numbers from clipboard 1 + clipboard 2 to clipboard 3.
The numbers can be positive and negative like:
’+3,4’ or '-10,6’
All I need is to add these clipboard numbers together, and put the outcome into clipboard 3… but I have no luck.
Example:
Clipboard 1 :-5,5 (As these numbers are fader values they always have a + or - upfront already)
Clipboard 2 :+3,5
Calculate Clipboard 1 + Clipboard 2
Paste to Clipboard 3

This must be easy to do but I not for me…
Any help appreciated

Here's a macro that will do what you asked.
But I have to say that using KM Named Clipboards is probably not the way to handle your workflow.
I would set a KM Variable to each number (maybe after a COPY Action), and then use another KM Variable to calculate the total.
Finally, just paste the KM Total variable to wherever you'd like.

###MACRO:   Add Numbers on Named Clipboards @Example

~~~ VER: 1.0    2017-03-11 ~~~

Add Numbers on Named Clipboards @Example.kmmacros (5.6 KB)

###ReleaseNotes

1. Must remove the "+" symbol from all clipboards before using in CALCULATE function.
2. Do the calculation in a Variable, then set the Named Clipboard.
3. There is probably a better method to accomplish this than using Named Clipboards.
4. I had to use a period (".") for the decimal point, since that is what my Mac expects.

Yes, "+5" is not a valid expression (or number) in Keyboard Maestro. It probably should be ok, but it is not.

Yes, Keyboard Maestro uses periods for decimal points, always, no matter what the language settings are.

Similarly, it uses commas for arrays of numbers (eg in Rectangles), regardless of the language settings.

Once they are in variables, and the commas and plusses are taken care of, you can set paste the result directly with something like:

Just to be clear, in Peter’s example, “Clipboard1” and “Clipboard2” are KM Variables, NOT Named Clipboards.

1 Like

Thanx a million!!
what a cool software… I am a real noob but its very intuitive in a way:)
The + and , thing was what made my attempts NOT work…
I learned again so much just by this one macro you sent …thanx again…you made my day

1 Like

Yes, the + I will endeavour to fix. The decimal point, that is too problematic to ever change since it would make sharing macros very problematic.