Nested scripts and KMVAR variable values – update/refresh?

My impression is that if a script

  1. uses KMEngine.doScript to call a macro, and
  2. subsequently reads KMEngine.Variables() to inspect the value of variables updated by the called macro

then the values retrieved are out of date (the unmodified values which they had when the calling script was launched).

If this is right, is there any way for the calling script to get access to new variables states which result from the .doScript call ?

( Context: the experimental progress bar plugin uses a series of .doScript() calls, and I wondered whether the calling applet could inspect their effects, update a returnValue variable accordingly, leaving that returnValue’s new state legible to the shell script which calls the applet : - )

( Matrushka doll territory here – the applet has to be called by a shell script (rather than directly by the plugin mechanism) to allow for the display of a notification dialog )

Shell called by plugin ⇄ Applet ⇄ .doScript mutations of variables

Its possible the AppleScript variables are being cached.

Can you build a simple self contained macro that demonstrates the problem and email it to me (or post it here) so I can take a look and see if I can duplicate the issue and ponder a solution.

1 Like

A simple test seems to give a null result (state changes made by a .doScript-called macro are seen by the caller), so perhaps it was either:

  • my misinterpretation
  • or something to do with calling .doScript from a running applet.app – a different thread from the KME engine ?

In any case, no problem at all here in this simpler setup (macro calls macro through Shell script action)
doScriptVariableExperiment.kmmacros.zip (1.4 KB)

The AppleScript handling code does make objects that I can imagine the AppleScript system caching, so I can imagine a case where it happens, but creating that case might be a challenge.