EXAMPLE Dynamic Variable.kmmacros (3.0 KB)
But this is all very convoluted and exactly what Keyboard Maestro dictionaries were designed to deal with in a much more direct way:
KM Dictionaries can directly use a dynamic value i.e. a variable for the Key:
To extract the value stored in this Dictionary entry we would write either of the below without any extra steps:
%Dictionary[Red,3]%
Or
%Dictionary[Red,%Variable%Index%]%
EXAMPLE Dictionary.kmmacros (3.5 KB)
Apart from being easier to use than dynamically named variables, dictionaries also create less clutter.
To do the same thing with variables you would end up storing lots of variables. For example variables called:
Red1
Red2
Red3
Red4
Red5
etc etc
But with a Dictionary you would just store a single Dictionary called:
Red