How I can change a Value in the "to:" Box in a "Set Variable" Action with Apple Script

My problem is simple (and the solution certainly too) but I can not find a solution and also not the right words

  1. I set a StartValue in a "Set Variable to Calculation" Action
  2. An AppleScript give back a modify Value for this Variable
    The Value is also in the KM Environment but
    —> I need the new Value also into the "to:" Box in the "Set Variable" Action
    otherwise when I start the Macro again, I reset the Variable with the "old" Value.

Sorry but I'm now stupid blocked ?!?!

Start Value: 2
AppleScript gives me back: 4 (the Value is set "in the Backround")
—> I need this 4 in the "to:" Box


You need a simple IF test to set the variable:

Replace you current Set Variable to Calculation with something like this (use your Variable name of course)


Thus, if MyVarName has never been set, it will be assigned the value of 2.
Else, it will continue to use the value last set in your macro/script.

thanks !
good idea and certainly a clear possible way ! and I will try it !

but the absolutely perfect solution in my case would be to call a little Macro or Action or Script that make a “hard” replace/overwrite/update the Value in the “to:” Box.
maybe you can give me a idea for this.

what I noticed is: Have KM no search & replace Function, where I can looking for a VariableName in a Macro and - in case of an hit - i can change/replace the value in the “to:” box ? I could not find :-/

many thx

May I ask what is your objective in doing this?

The KM Editor, is, well, an editor, which does not normally run your macros. So, if you want to change the value of a KM Variable, you can:

  1. Run a macro which contains a Set Variable, or other action which changes a variable (like Prompt for user).
  2. Run a different macro which makes the change.
  3. Run a script which makes the change.
  4. Manually change it in the KM Preferences Variables tab.

BTW, you can also use the Set Variables Action to set a variable to another variable, like this:


Does this make sense?