In many of my macros I set several local variables to zero at the start of the macro. I never thought to ask myself if I can set several variables at the same time in the same action. I even asked ChatGPT but it said "no" (but it did show how to do it with multiple macOS "osascript commands" or multiple AppleScripts's "set variable", which I think is too much work to be useful.) It also showed a way to do it if the variables shared the same prefix, like the string "Local":
The above action will set two variables, called "LocalWidth" and "LocalHeight". Since many variables begin with the word "Local" or "Instance", that approach could help me out in a few cases. But all those quotation marks don't make it easy to type.
I also found an old post in which The Architect explains how it could be done in another special case: (when the variables end with sequential numbers)
The above approach could also help me out in a few cases.
But today I found a way to do it, which proves ChatGPT can be wrong. Here's my method:
That will assign several variables with any set of names to four separate values. Best of all, you get to see the assignment values in the macro, and you don't have to use quotes.
I suspect that many people will still consider this too much work to assign a small number of variables, but I like it anyway.
I did some speed tests, and found that the Search Text action costs exactly as much time as two Set Variable actions, regardless of how many variables you set in the Search Text action. As a result, it's actually faster to use this action if you have more than two variables to set. So if speed matters to you, this is the faster approach.
Don't forget, the Text Box can contain tokens, including tokens that can return different results, like %Calculate%%. Oddly enough, this action doesn't contain any flags to disable token processing. I would suggest that this is a feature omission.