I'd like to have one action to set values for multiple variables.
It will be like the Prompt for User Input action, just without the prompt and the values are all the default values for the Prompt for User Input action.
I haven't actually written the code that makes the plug in work, but I specified (in the plist file) that the field containing the variable/value pairs is of type TokenText, so yes you could use any tokens that you like and the KM engine will take care of it for you.
To implement the code you'll need to edit the action.scpt file. Personally, I would use AppleScript to split out the pairs and perform the assignments.
Sorry if I wasn't clear - it's just that I've already done something vaguely similar with one of my own plugin ins and thought I'd give you a kick-start by suggesting an alternative to waiting for an enhancement to KM to come along together with a "template" for you to work on and thus "roll your own".
If you're not confident with taking this further, let me know and I'll put something together by this weekend (I'm busy right now) and about to go to bed...
Yes, it is good idea to have a single action to initiate variables.
In the meantime, if need quick solution without using plugin , you can try the following actions.
I use @= as delimiter to reduce the possibility of data having that as delimiter ( you can use Search Action using regex to extract data but for simple need, this maybe sufficient.)
The other constraint is that data must not span multiple line.
I generally don't like implementing multiple implementations of the same basic functionality (when I do it is because I want a new one to replace the old one but can't actually remove the old one).
In this case, you can collapse all the Set Variable actions which would give similar height, and double clicking an action to edit its value (double click in the title is shorthand for collapse/expand) will let you edit them.
There are additional options for the Set Variable action, most particularly how to process tokens, which would have to be all-or-nothing with a multiple-variable setting action, so that is one problem.
So basically, while this is an interesting idea, I can't see implementing it I'm afraid.
There are many actions in KM can be removed and we can still do the same work with other KM actions. The point is if they are removed, we may need more actions to do the same job, and doing this will add more actions and take more time. Therefore, having those actions is perfectly justified, because they save time for users. This is also the main point of my feature request.
Thanks, Chris. I did mention this in my OP.
Thanks for posting your macro. There is much I can learn from it.
Thanks, @tiffle. @macdevign_mac and @ccstone have posted alternative methods. I think I'm ok to use their method. But if you could make a plugin, it would be great. The advantage is that only one plug-in action is needed.
To install the plugin just download the zip file and drag it onto the KM icon in the dock. Then be sure to quit the KM engine (in File>Quit Engine) and then restart the engine (File>Launch Engine). The plugin will now be available as an action to add to your macros as normal.
The default appearance is this:
and in use it might look like this:
As you can see, you can specify a delimiter to separate the variables from their values (the default is ",") but you can be more adventurous as shown in the example.
You can also use variable tokens as shown.
Each variable/value pair must be a single line of text even after any tokens have been expanded.
The plugin in will fail with error code -999 if it encounters ANY error - such as multiple-line assignments, or incorrect/mismatching delimiters. In such a case a brief notification will appear while the full error message can be found in the KM log.
If you use the plugin you do so at your own risk and I accept no liability for any loss; I have performed limited testing on the plug in so I am confident it will not misbehave, but YMMV. You have been warned.
When I get time I will post this plug in to the Plug Ins category of the KM forum, but that won't be for a few days now.
Hope that helps but if you use the plug in let me know how you get on.
It works great! Since Peter does not have plan to implement it, and your plugin is closest to my feature request, I'll mark it as the answer so that others who search for it may easily see it. Thank you very much!
BTW, I've seem many examples where multiple actions are used to just clear some variables when the macros are done. This plugin will serve well for that purpose as well. Just leave blank after the comma (set as the text delimiter):