Calculation Issue Variable + 1 Yielding Variable + 2

Hey Forum members,
I am a new user and this is also my First post, so please forgive any lapses in etiquette.

I am using Pro Tools and having an issue a macro that i have written for the "add bar | beat marker" window. ( i will attach a screen shot of my macro below) i have it to trigger when the window appears, copy a field, run a calculation (variable + 1), tab 3 times, paste the calculation, delete my clipboard, and hit the ok button.

my problem is that when the original field is an odd number my calculation will yield the correct value ( variable + 1), however, when the original field is an even number my yield will be 2 higher ( variable + 2).

i have not been able to understand why it is doing this. hopefully the community can help.

again, i am a new user to Keyboard Maestro. i am sure that there are lots of levels that i haven't even known to look for. thanks again.

-b

Also, it seems to exhibit the same behavior regardless of whether i have my calculation set to (Variable + 1) or (Variable + 1.0)

Using simple macro to try out, KM giving correct answer

  • Use Local variable if possible , rename First_Bar to Local_First_Bar,
  • put delay action after copy action. Without this delay, the variable assignment from clipboard may not work reliably.

Hope this solve your problem.

Have added your change to a duplicate copy of my macro. it will display the correct figure for odd numbers, but even numbers are still yielding variable + 2 ( . . . 5 changes to 6, 6 to 8, 7 to 8, 8 to 10. . . etc).

but it did tell me that perhaps there is something wrong with my calculation, maybe?

i suggest use Display Action to find out the value for First_Bar after calculation to ensure that the calculation is correct first. What did you see the value after calculation ?

I suspect that it may not be KM issue but the way the Pro Tools work ?

i have added display text after each command:
the field that KM is copying displays as X | 01 | 000 (X= copied number)

the result of the Calculation.

it is showing the result of my calculation being wrong. anytime i have an odd number the calculation will perform correctly. when the value copied is even the calculation will give me (Variable + 2)

it doesn't seem to be an issue with the way that Pro Tools is handling the information, as the display is showing the calculation not coming out right

Screen Shot 2021-03-23 at 12.23.19 AM

I deconstructed my macro and can confirm that the anomaly only occurs when the copied data is "X | 1 | 000" (but again, odd numbers return the correct calculation, only even numbers aren't working correctly)

is there a (simple?) way for me to change the clipboard before running my calculation?

Ic. So the input copied is not in numeric format in the first place.

You need to extract the X value out correctly in the first place

To extract use this:

%Variable%Local_First_Bar[1]|%

Thanks Much. Will test this and report back.

Thank You @macdevign_mac
all is working now. here is a screen shot of the working macro for "Identify Beat"