Doubts about the use of %Variable%

Hello, everyone. I've encountered an issue: I wrote a macro similar to this for cleaning variables, but it doesn't seem to work until I changed "local_variable" in the "set Variable to" to "%Variable%local_variable%." This has left me puzzled. Why does it need to be written in token form here? In contrast, when using 'set Variable to text,' it doesn't need "%Variable%"


You're looping through the Variables collection, which includes every variable available in Keyboard Maestro.

When inside the loop, local_varriable is a placeholder variable used to reference the current item in the collection for each iteration of the loop.

Say your variables are [Var1, Var2, Var3,...]:

In the first iteration of your top loop, local_varriable is equal to the string "Var1", and then you set local_varriable equal to %Delete%, overwriting the string "Var1".

In the first iteration of your bottom loop, local_varriable is equal to the string "Var1", and you get that string using %Variable%local_varriable%, which is processed into "Var1", so you set Var1 equal to %Delete%.

Here are some bonus threads by forum veterans regarding deleting variables:

3 Likes

It turns out that's how it works. Thank you very much for patiently explaining it to me. I appreciate it. :+1:

1 Like