How to Combine Two Variables to Reference a Third Variable?

I am capturing several tab-delimited "Coordinate" charts and saving them as variables. These are then parsed to position artwork in a corresponding template for a certain laser.

image

The same artwork is placed in up to 3 templates using a loop macro. Right now I swap the current template coordinates into a generically-named variable, "Coords":

image

To parse the coordinates:
image

Is there a way to point to a variable by concatenating two variable names and have it point to a third variable. I'd like "Coords%Variable%Laser%" to point to "Coords_C4" for example.

I may be a bit confused here, as to what you want, but I think there's a KM action that you haven't considered....

image

What this does, I think, is evaluate the name of the variable that's stored in V1 and place the result in V3.

Think of it like this: (hopefully I'm not wrong. If I'm wrong, someone can correct me. Even if I'm wrong, I'm pretty close to being right :wink: )

V3 := Evaluate-Variable-Stored-In(V1)

Using that method can probably solve your problem, because you can set your variable V1 to any string you want. In theory that is documented on the following page, but some of KM's documentation doesn't state any more than the action itself already does:

manual:Filters [Keyboard Maestro Wiki]

There's also a totally different way to solve this problem using AppleScript, which you can read about here:

AppleScript [Keyboard Maestro Wiki]

However as I meditate on your problem, I think you are doing it all wrong. You should be using dictionaries. This is a classic example of when they should be used. Let me paraphrase in my own way what a dictionary would let you say, essentially:

MyCoordinateDictionary["C4"]:=57.00

5 Likes

@Sleepy, thanks for the insight. I'll give it a try and report back.

You are welcome. Most days I like to wake up and come to this website immediately because I'm never completely awake until I reply to a few posts. (Even then, I'm still not completely awake.)

1 Like