Hi, I often reuse groups of macros. How can I run a 'group' inside a macro, so that I can reuse such groups and don't have to re-create them, but can reference them?
Feel like this must exist somewhere, but I can't find it. I also could not find anything by searching..
Thank you so much for this! Very interesting...
Yes, I meant group of actions within a macro.
Question: When I 'copy as XML', does it copy just the reference to the group of actions?
My intent is to have a set of 'template' action groups strored in some macros that I can reference anywhere else. This would allow me to change just one action group, instead of dozens every time (I organize my complex macros mostly through 'action groups'.
To add to the excellent comments above -- what you use depends on how you want to "reference" these groups of actions.
A sub-routine is a "mini macro" you can use in other macros. The big benefit of using them is that you can make a change in the sub-routine and all the macros that use it immediately benefit from the change -- you don't have to make the same edit in 100 different places. The downside is that while you can "individualise" a sub-routine so that it behaves differently in different macros that can soon get pretty complicated.
You can also put a bunch of actions into a Group action then Favourite that Group. This is a "template" system, making it easy to add those actions to a macro in the Editor, and that macro's Group is independent of all others -- you can make changes in one without effecting others.
A good example of a sub-routine would be a checkout or invoice calculation -- pass in item costs and number purchased. Your sub-routine would then handle the dialogs for tax rate and shipping options and return a total price. You could use that in many macros, and when tax rates change you only have to make one update.
An example of a Favourited Group could be an "incrementing loop" routine where you are always going to want a variable, a loop, a test, an incrementer -- but what happens in the loop will vary macro to macro.
I like alternative solutions, so I'm going to place an alternative solution here. It's not for everyone.
There are times when I didn't want to write subroutines or external macros but I still wanted to avoid the need for copying the code into two separate places in the same macro.
So what I did was create an infinite loop with an internal switch statement that allowed each switch clause to specify which clause would be executed next. In a sense, each switch clause is a "label' and the last line in each switch clause was a "goto." That's not exactly good programming practice, but it allowed me to keep everything in one macro without duplicating my code in separate locations in the macro.
Here's a template to give you the idea, with some different ways to branch as examples. Before you start the loop, you have to set the value of NextStatement to a number from 1 to 5.
What a great conversation. The 'subroutines' gets closest to what I am looking for. I actually already use it, without calling it such. Now knowing from this convo that I cannot reference action groups directly, I can just 'wrap' them in their own macro each...one 'level' higher than what I hoped but guess it can work..