Macro not stopping where it should

My macro should provide an user dialogue that determines the beginning and end of an certain automated operation.
I got this all running so far but it doesnt stop when the beginning-value is equal the end-value but goes on-and-on.
Can anybody help?
Sort Marked Makro copy.kmmacros (11.6 KB)

It looks like your until condition at the end of the macro is expecting the Beginning variable to literally be "End". What you need is to set the condition to is= as seen in the screenshot (highlighted blue portion).

Edit: on another note it looks like your macro makes use of the execute a macro action, but that portion of your macro will never work on other folks computers since they won't have that other macro. So when sharing to the forum it's best to temporarily embed that subroutine directly into your macro in question in case we need to actually execute the macro to debug it. :grin:

Image (click to expand/collapse)

Screen Shot 2022-01-30 at 15.17.25

Great.That helped.
Thanks a lot!

1 Like

Ok good! If that ends up being the solution feel free to mark my comment as the solution that way it's marked as solved in the forum. :grin:

Hi again,
One further question.
I'm kind of diving currently into the variable world within KM.
My macro starts with asking the user for a beginning value and an end value and then a certain action is repeated and after each cylce my beginning value adds up +1 until the beginning value matches the end-value.
Now I would like the initial beginning-value to be stored so I can use the initial value of that variable for a following macro. How can I do that?
Thanks again, Simon

Hey Simon, that's a great question and there's a real easy solution to it.

In your prompt, where you currently have 1, put in the following line:


You can see it in the screenshot below.

What that does is displays the existing value of the variable named Beginning. The line separator between that and the 1 converts this into a dropdown menu. So now if you click on it, you still have the option to set it to 1 in case the Beginning variable for some reason no longer contains 1. You can have as many items in the dropdown as you want; just separate them with a line separator.

On a similar note, since you're just getting started with variables, I highly recommend taking some time to learn about instance and local variables, and use them whenever possible. They are great because they do not exist beyond the execution of the macro so your variables list in the preferences pane will not grow insanely huge as you inevitably go down the black hole that is creating more and more macros haha.

For any global (or permanent) variables, think of a naming convention for them so you can readily identify what they are used for.

To give you an example, all of my global variables used for work are prepended with "LB" (the initials of the company I work for), that way I know right away what they're for. Other global variables follow a similar structure.

If none of that made sense or you have any other questions don't hesitate to ask! :grin:


Hey Chris,
Thanks a lot. The dropdown option is really interesting but in my case I think it doesn't solve the problem. I try to specify my challenge.
There are those user-defined variables 'beginning' and 'end'.
My first macro operates a certain routine, increases the beginning (+1) until 'beginning' is= 'end'
After that I would like to run a second macro that deals with the same two initial variables 'beginning' and 'end'.
'end' still has the same value but beginning doesn't (it has now the 'end' value)
My question is there a way to somehow save the inital beginning value so that I don't have to ask the user again for the beginning and end value.
I hope you understand the issue.
Thanks again,
Great forum! Best,

Ah yes! Thank you for mentioning that because I don't think I fully understood your most recent issue initially.

That's definitely doable. What I recommend is making two variables, and prepending one of them with something along the lines of DND__ that way you know it's the "permanent" variable.

The other one you can use in your macro for the calculations.

For example, you can use DND__Beginning to store the number used at the beginning of the variable for subsequent executions, and Beginning to run the calculations.

The macro below is just a demonstration of how you can setup the variables. The screenshot shows it in action to show you how the original variable is persevered even upon subsequent executions.

A screen recording of the sample macro

A closeup of the prompt to show it retaining it's value from the last execution

Use global variable for subsequent macro executions.kmmacros (4.8 KB)

Macro screenshot (click to expand/collapse)

Chris, you are a genius!
Perfect. Thanks man...

1 Like

Don't go spreading that around now :laughing:

Haha no problem, always glad to help when I can!