Set Multiple Variables Plug In Action
Purpose
The TFL Set Multi Variables Plug In action for Keyboard Maestro provides the ability to assign values to many KM variables with a single action, instead of having to use a separate KM Set Variable action for each assignment.
Benefits
- Using a single action instead of many to set the values of variables keeps the overall size of the macro small and is quicker to create.
- It is easy and quick to disable/enable multiple variable assignments with a single click, for debugging purposes.
- The plug in reports all errors in the KM log in a way that makes identifying errors very easy.
Download
Download the plug in file to your Mac:
TFL Set Multi Variables.zip (552.8 KB)
Installation
- Drag the downloaded zip file from Finder and drop it onto the Keyboard Maestro icon in the dock.
- Stop the KM Engine using File>Quit Engine.
- Restart the KM Engine using File>Launch Engine.
- The TFL Set Multi Variables plug in action can now be added into your macros as normal from the Third Party Plug Ins section of the KM Actions library.
Usage
After adding the action to a macro you will see this:
The Variables__Values field is where you list the KM variables with the values that you want to assign. These Variable/Value pairs must be separated by the delimiter specified. By default, the delimiter is the comma (,).
Each Variable/Value pair must occupy just a single line of text even after any tokens have been expanded - any more and the plug in will generate an error.
Examples
Example 1
Set Multiple Variables Example 1.kmmacros (2.9 KB)
This example shows a possibly typical use of the plug in.
Notes
- You can use tokenised variables to specify the values to be assigned. In this example the value of %Variable%LocalVariable% is assigned to Local_Var1.
- The delimiter is very flexible. Here it is set to == which possibly makes reading the assignments much easier.
Example 2
Set Multiple Variables Example 2.kmmacros (3.1 KB)
This macro shows the use of a KM variable to hold the assignments.
Interpreting Errors
While using this plug in you will probably encounter occasions when it throws an error and stops the execution of your macro. The quickest way to find out what has gone wrong (if it isn't obvious) is the look at the KM Log.
In the KM Editor use the menu Help>Open Logs Folder and then open the Engine.log file. Easier still, just use this macro
The log file will contain 2 entries describing the error, as shown here:
The first entry (labelled "A") comes from the plug in while the second entry ("B") comes the KM engine. In both cases the information can be interpreted as follows:
- The timestamp for the error.
- What the error occurred in (the plug in)
- The error message.
It is the third one, the error message, that tells you what went wrong.
In this example
"Bad assignment for Instance_Var2=This is instance variable 2"
tells us that we mistakenly used an incorrect delimiter: it should have been a double equals sign "==" rather than a single one.
Disclaimer
You use the plugin at your own risk and the author accepts no liability for any loss; Testing of the plug has been performed but YMMV. You have been warned.