[SUGGESTION] "Anchor" action

More than once I saw myself in need of something that would send the "playhead" of the macro to a specific place in the macro.
If we could have an action called "Anchor" for example, then we would be able to have another action that would send our "playhead" to that anchor. Similar to how we can add anchor links in HTML.
This would require something similar to "Execute Macro" as well, but for that "Anchor" action like "Execute Anchor" or something like that.

So for example if I have 10 actions and I want action 10 to send my "playhead" to action 4, I would add the "Anchor" action right before action 4 and it would play from there. This is useful for creating different loops and also allow us to control flows by pressing buttons, for example:
If I press button A the flow goes to action 2, if I press button B it goes to action 14.

Hope it makes sense.
It seems that there's nothing like this yet, unless you create another macro, maybe, and make that macro an empty macro? But the "Anchor" action would avoid adding more macros, especially empty ones to avoid clutter.

Your proposed use of "anchors" leads me to think you have reinvented GOTO statements. This is a recipe for spaghetti code.

Where you think of an anchor point, think of it instead as the start of some actions that you could break out into a discrete unit that you could call as required. That's it, we're talking about (in the widest sense) subroutines :partying_face: or at least of structured programming in general.

Keyboard Maestro does not have any form of goto, instead it uses the structured forms pioneered by the likes of Dijkstra, namely:

And the various Redirect Control Flow actions.

So if you want to return to action 4, then place the actions from 4-10 in a loop.

You can get any form of loop with something like:

  • While 1 do
    • If condition then Break From Loop

You can also use the Switch action to form a state machine.

It's unlikely I'll implement Labels and Goto.

1 Like

We're still getting COMEFROM in V. 11, right? :laughing: