This is a tip. I discovered that KM actions can return string values.
WARNING: When Peter reads this he will likely say this is a dangerous technique. One possible reason he may say this is that it might cause memory leaks. So as a courtesy to Peter I won't upload the macros, I'll just post some images of actions and give the general idea so that noobs don't actually try this. But it's so fun!
(I can't really confirm if it creates a memory leak because the KM Engine is always giving me memory leaks. I have to restart it several times per day when my system grinds to a halt after the Engine is using >8GB of RAM, when my system has only 8GB of RAM. I've given up trying to fix it, I just reboot it hourly. This also helps to reset the Find Image action which often gets into a bad mood until the engine restarts.)
The basis of this technique is the underlying mechanism of how the %ActionResult% gets it value. By doing a little hypothesizing, experimenting and observing I noticed that I can return anything I want from a macro and place that result into the %ActionResult% token.
Here's the germ of the idea. Let's say you want your function to return the string "Paris" in the %ActionResult% token. Here's what you place at the end of the action:
I won't try to explain how it works, (if you're a noob you don't need to know) but I will say that I figured this out on my own. This will generate an error string which is passed back to the %ActionResult% token, and the string will contain some gobbledygook which includes the word "Paris". So in the action which gets that result returned you can easily check if the string contains the word "Paris", perhaps like this: (notice the word CONTAINS below)
Now that's the short of it. But there are a few extra details to be aware of. Firstly, you can't return the strings 0 to 31 because those strings are used by KM to return certain conditions like "OK" (more on this below). Anyone can figure out how to work around that. Secondly, there may be some characters that can't be returned. I haven't tested the entire character set but basic alphanumerics are fine and that's all I need as a programmer. Thirdly, the actual string being returned includes some gobbledygook. But it seems fairly easy to remove that superfluous text. I use this action to remove the text:
If you do the above, then you can replace CONTAINS with IS for more accurate programming.
Fourthly, did I mention the memory leak? I actually have no way of testing if it causes one. Perhaps someone here with a more stable implementation would be willing to test that idea.
Fifthly, you need to be careful that your macro doesn't actually contain any other errors as they will override this value. But if you exit the macro after setting this value it shouldn't be a problem.
In addition I should point out that when you issue the kill command it doesn't terminate the macro. In fact you can issue multiple kill commands in a macro, and only the last one's value will be returned to %ActionResult%.
I mentioned the values 0-31 earlier. These are values that KM seems to support (it uses them for its own purposes) so these values may be stable, by which I mean not cause memory leaks. But they have some odd patterns. You can see some of them return nothing but "OK", while some of them return a text string with a number (all of this goes into %ActionResult% after the parenthesized number), and if you are eagle-eyed you will notice that some numbers are missing, because the action simply aborts with no error. I suppose this might be a bug but Peter would reply "it's not a bug if it's not a feature." LOL.
* (31) Task failed with status 31 * (30) Task failed with status 30 * (29) OK * (28) OK * (27) Task failed with status 27 * (26) Task failed with status 26 * (24) Task failed with status 24 * (23) OK * (20) OK * (19) OK * (16) OK * (15) Task failed with status 15 * (14) Task failed with status 14 * (13) Task failed with status 13 * (12) Task failed with status 12 * (11) Task failed with status 11 * (10) Task failed with status 10 * (9) Task failed with status 9 * (8) Task failed with status 8 * (7) Task failed with status 7 * (6) Task failed with status 6 * (5) Task failed with status 5 * (4) Task failed with status 4 * (3) OK * (2) Task failed with status 2 * (1) Task failed with status 1 * (0) OK
I haven't really decided yet if I'm going to write programs that use this trick. I do worry about its stability. Let's see what the experts have to say about this. I'm just an average user who uses KM a lot.
Even though this idea is likely to be rejected by the experts, I came up with a couple of other great ideas last week that will probably be accepted when I post them later.