Shortly after discovering the existence of variables as real drag-n-droppable objects in Applescript Studio, I ran smack into a big limitation: the linear flow of an Automator workflow does not seem to allow for storing and recalling multiple values at once. Fortunately I was mistaken, as I discovered by accident while examining the ‘results’ view of each workflow object as it received data from upstream objects. We begin with a touch of background.
At first blush, the “Get Value of Variable” action seems like it can only really be used in conjunction with “Set Value of Variable”. You’d use “Set” to catch the output of some upstream object, and then store the value for later use.
For those actions which do not support direct use of variable objects (e.g. “Name Single Item in Finder Item Names), one might instead try to pass the variable data as input, by connecting the input of a “Run Applescript” object to the output of “Get Value of Variable”, as long as you’re prepared to hand-write the stuff you need in Applescript.
That’s all well and good, until you realize that you need to use more than one variable in your “Run Applescript” object. For example, let’s say you’re writing a file re-namer – you might need to pass in the file extension of the ‘old’ file name, as well as the ‘new’ file name. “Get Value of Variable” can only recall a single variable’s value.
Here’s the trick: “Get Value of Variable” ALSO acts as a pass-through for whatever it receives on input, which allows you to stack multiple “Get Value”s, and then connect them to “Run Applescript”. In the “Run” object, the value of ‘input’ will be a list of the values received. In the below example, I’ve got a pair of “Get”s under another object which outputs a file / folder reference, then all of that output is dumped into a “Run” object. Those values are then accessed in the standard fashion: “the first text item of input”, “the second item of input”, etc.
Finally, the “Get Value” behavior of accepting input can be disabled by control-clicking on the “Get Value of Variable” title text on the object.