BUG: Version 11 - Set Variable to Text - Variable Name by Indirection - Variable Name from Array with Custom Delimiter

This is a simple test macro to attempt to set the value of a variable (foo), where the variable name is specified by indirection from an array of text values.

It's abstracted from a complicated workflow that we have been using successfully for a number of years.


Set Variable by Indirection Test.kmmacros (4.0 KB)

The expected result of running the macro is that the variable "foo" is assigned the value "bar".

I have tested the macro in version 10 of Keyboard Maestro and the test macro works. However, in versions 11 and 11.0.1, the macro fails with an error message:

2023-11-10 13:06:26 Set Variable to Text failed to set variable “(null)” (from “%Variable%InstanceArray[1]:%”). Macro “Test” cancelled (while executing Set the Variable to the Listified Numbers).

Notes:

  • The variable name is obtained from a text array with a colon as a custom delimiter.

  • The disabled "Display Text" step, when enabled, correctly reports the variable InstanceArray[1]: as having the value "foo". This is in both versions 10 and 11.

  • The manual page for Set Variable to Text appears to indicate that all that is required for a variable to be specified by indirection is to enter, in the Set variable field of the Set Variable to Text step, a token that resolves to the name of the variable to be assigned.

Has anything changed in Version 11 that might cause the observed behaviour?

Does anyone know how I can modify the macro so that it works in version 11?

Thank you for any help you may be able to provide.

Yes, the issue is that if the Set Variable to Text action variable has a [ then Keyboard Maestro is deciding that it is setting an array component of the variable.

So it is treating it as if the variable name was %Variable%InstanceArray and setting the first indexed entry of an array separated by :%.

I will adjust the parsing to try to more accurately choose whether the array entry is part of the token or part of the variable.

Thanks.

Thanks very much for the quick reply, Peter. Look forward to the fix being rolled out.

BTW, you can work around it by using a temp variable.

  • Set variable “LocalTemp” to “%Variable%InstanceArray[1]:%
  • Set variable %Variable%LocalTemp% …

Thanks, Peter. I'd already realised I could use a temp variable as a workaround. I confirm that it allows our workflow to perform as expected.

1 Like