Execute Macro has a powerful feature of an optional parameter:
But it seems that this parameter can't be a KM variable... the parameter is taken literally.
Is it true?
Thanks,
--Alain
Execute Macro has a powerful feature of an optional parameter:
But it seems that this parameter can't be a KM variable... the parameter is taken literally.
Is it true?
Thanks,
--Alain
I will fix that for the next version.
Well With Parameter is for Execute Macro action input through %TriggerValue% token.
BTW what “clean” way you should recommend to access textual output of this same Execute Macro avoiding potential conflict in call chain?
– Alain
Also trying to make this work.
I have a macro that processes text (Macro B) on a Variable. I want to reuse it with several Variables, with the variable being dynamic (not pre-defined, since I want to be able to change the Variable being processed on the fly).
For example, Macro A:
• Execute Macro B to clean up %Variable%thing1%
• Execute Macro B to clean up %Variable%thing2%
• Execute Macro B to clean up %Variable%thing3%
Right now for each of the variables I want to process I am using:
• Set variable %temp% to %Variable%thing1%
• Execute Macro B (which always processes %temp%)
• Set %Variable%thing1% to %temp%
Is there a way to avoid the need of setting a %temp% variable before and after I execute the macro, by using the “With Parameter” option to pass a variable name to Macro B?
Hope that made sense and thanks in advance!
This is the best I could come up with. By the way, you can get the "With Parameter" parameter by clicking the "gear" icon.
I have posted the following macro which should do what you are asking for.
Thanks for the time you put into this Dan!
Wow this is great, I wasn’t sure if it was going to be possible but this looks like exactly what I needed. Going to download them and figure out what you did so I can use them in the future. Looks like I also have something to learn in the way you formatted/organized the macros - that’s a challenge I have is that some of my macros are literally hundreds of actions long so it is really hard to not get lost later
Thanks again
No problem. Good luck.
Can the parameter be used in a simpler way? I just want to pass a constant string without needing any tokens or variables in the calling macro. Can I just put the string in as a parameter? How would I access its value in the executed macro?
Yes. Just put the string in the parameter.
You access it via the %TriggerValue% token.
So here's an example: This is the macro that gets called:
And heres the calling code:
Got it. Thanks. I was misreading the examples that passed a variable rather than a value.
Yeah - that was the “advanced” version.
Though actually, why is this any better than setting a variable and using that variable in the executed macro? More elegant, I guess.
Variables are shared by all instances of all macros - the %TriggerValue% token is unique to each instance. So if you had two macros, each executing the same macro, %TriggerValue% would work, but using a variable would fail as whichever was second would clobber the value of the first instance.
Of course, most people don’t use multiple instances of a macro simultaneously, and likely the macro will fail anyway if there are multiple instances and you have not taken care (eg by using a Semaphore action).
Definitely more elegant. The other method requires you know that you have to set a variable, and what the name of the variable is. If you decide you want to change the name of the variable, say, because you've come up with a new variable naming scheme, you have to find all references to the macro and change them.
The second method only requires you to set a parameter, and there's no variable name to have to change.
Other than that, no reason. If you have multiple values to pass, it's often easier to use variables.
I usually put code like this at the top of the called macro:
Just to make sure I don't forget to pass the parameter. I keep this code in a named clipboard, and have a macro that pastes it in. Easy.
How do you do this now that KM V8 only seems to have Alert with no execution option, i.e. it just Aborts the macro?