Because I've struggled with this previously, including going so far as to write an (unnecessary) plugin, I thought I'd share these examples.
Set Value of Variable by Name
Set Value of Variable by Name - Macro Example.kmmacros (2.6 KB)
Get Value of Variable by Name
Get Value of Variable by Name - Macro Example.kmmacros (2.5 KB)
4 Likes
###Here's another example, used by a sub-macro that is passed a Variable Name as a Parameter (TriggerValue):
![](https://forum.keyboardmaestro.com/uploads/default/original/2X/e/eb164abd0d619867002e7f2aed3630e8fc5a6311.png)
This uses the Filter Variable with Value of Named Variable that @peternlewis just showed us in another thread.
It is used in this macro:
[KM] DELETE List of KM Variables [SUB-MACRO]
2 Likes
Hey Dan,
Okay, lets throw in an extra layer of abstraction.
-Chris
Get Value of Variable by Name - Macro Example.kmmacros (3.0 KB)
![](https://forum.keyboardmaestro.com/uploads/default/original/2X/7/7a5d55e7b9dd8ba7172e129b56681615437a211b.png)
2 Likes
You don't really have a use for this, do you?
Hey Dan,
I have used it a few times, but I don't think I'll need to now that Filter with Value of Named Variable exists.
Probably. ![:smile: :smile:](https://forum.keyboardmaestro.com/images/emoji/apple/smile.png?v=12)
-Chris
2 Likes
Yep, that's a cool Action/Filter.
I finally had a need for your example. Thanks!!
1 Like