You suggested I use the asynchronous option in the Execute Macro action. Funny, I never thought that if I did that and followed it immediately by a Cancel Just This Macro action, then I think that would achieve the same thing. That idea had never occurred to me. E.g.,
So that's an equivalent to the Branch idea that I was proposing. Brilliant. This is a very close to a GOTO/LABEL action, especially if you use a parameter that includes the state for the next Macro to start in.
Then you asked "Why not use the Macro’s UUID instead of the name then?" The answer is that I'm a lousy programmer who can't think of everything. Thanks for that excellent tip. That's why these forums are so great. (Maybe I should have used the handle Dopey for this website instead of Sleepy.)
Lastly, you asked me to consider using a state variable approach. That's what I did in the example above, and it's how I usually solve these problems, and it functions correctly, but the performance (in the KM Editor) is poor in many cases, which is likely because I typically have 10-20 states in a loop, and then more state loops after that, often they are nested. Eg, if I try to expand a block it often takes 3 seconds from the time I click until the Editor opens the block.
Although I can't be certain, I suspect it's because the KM Editor pauses a lot to "recompile" after each edit. Is that correct? Is there a way I can turn off the auto-compile feature temporarily? This is my biggest technical problem with the KM Editor. The editor freezes a lot, sometimes even losing my keystrokes, because it's busy recompiling. So for example if I run this code:
...there is usually a two second gap between the first and second beep. I think that's because of the auto-recompile feature of the Editor which freezes the engine. In fact I don't even have to change the code for the freeze to occur, all I have to do is expand/contract an action, without changing anything, and it still freezes. There is so much freezing that even if I'm typing text in a window, the editor often freezes while I'm typing.
Make no mistake, I love KM, but the thing at the top of my wish-list for it is to give me more control over the auto-recompile timer. This is all relevant to this thread because I think it's a factor why the SWITCH-IN-A-LOOP approach is unsatisfactory.