Breaking Up An "Array" Into Calculated Variables

I'm sure I'm missing something simple.

This works:

Screenshot 2023-03-31 at 5.03.53 PM

But I can't skip "step 2". I've tried variations of setting local__x to:


Am I missing something obvious?

The problem you're running into is that specifying items in a variable array is done via a text-token.

VariableName[#] doesn't work – you must use the form of:


You can also specify a delimiter different than the default comma.


You cannot use “hello,123,234,234,234” in a calculation. If you have it in a variable, you still cannot use it in a calculation, nor could you use VarName[2] in a calculation and expect to get 123. “hello” is not a valid numeric value.

VariableName[#] will work fine if it is in a calculation, and if VariableName contains a sequence of comma separated numbers, and if # is a calculation that returns an index within the range of the array.

But it will not work in a calculation if VariableName contains non-numeric parts. It will not work even if the index points to an entry that is numeric.


Always start by showing us the output you are aiming for:

(without that it's harder than you would guess to interpret the context and the actual problem that you are trying to solve – see XY problem - Wikipedia, and harder than it need be to actually offer you a solution)

Are you, for example, trying to produce a second list, derived from:


and with the same calculation applied to each comma-separated segment that is numeric ?

e.g. assuming that the calculation were (* 7), an output like:



Or perhaps:

  • applying a different calculation to each column ?
  • extending this pattern over several CSV lines ?
1 Like

Apologies for not posting more details. What I was trying to do was to build a save/restore window positions macro system. I tried to adapt some of the ones I found on the forum, but using dictionaries and/or JSON is a bit beyond my current skills. So what I did was to save window names/positions as strings, like:

But @peternlewis made it clear that my "windowName" will cause problems.

I was able to get it work by saving the values to intermediate variables.

Thanks for the feedback!

restore window positions Macro (v10.2)

restore window positions.kmmacros (8.5 KB)

Keyboard Maestro Export