Normally an AppleScript waits. It will execute the commands, functions, whatnot, in order, not asynchronously. Of course, there may be some glitches when external things are involved, like saving a huge file to disk.
But in AppleScript you also have the dalay command, similar to the Pause action in KM. Try to place it on different locations in the script and see if it changes something. If you think it is a timing issue.
tell application "Keyboard Maestro Engine"
setvariable "fileLocation" to result
end tell
ā¦is meant to refer to what? (Which result, I mean)
You had already saved result to theFIle in the previous Tell block, no?
Any reason you are leveraging result here? Syntactically all seems correct (AFAICT without Daylight). Iām only asking for confirmation if you are doing what you intended to do.
This is also often called āisolating the issueā. (Not exactly the same, but pretty much.)
Strip off as many actions as possible from your macro until the issue disappears (or the core functionality of the macro stops working).
I know, in your case it is probably (but not definitly) related to the AppleScript. Do the same as said above in addition with the AppleScript: Strip off as many functions, variables, lines as possible until the issue stops appearing ā or the core functions of the script stop working.
Just try to remove as much as possible: any secondary features, anything that isnāt essential (in terms of script mechanics), while still being able to produce the issue.
Then post the stripped down script and macro. This will greatly help to get a solution.
Besides that, it often happens that in the process of building a minimal example (i.e. trying to isolate the thing) the issue suddenly becomes obvious ālike the shining sunā [replace this with a good idiomatic expression]. I have experienced this countless times.
Iām not saying this to say something, itās a serious recommendation that may help you to get a solution until Thursday. I will try to help you maybe tomorrow or Thursday afternoon, but if you could already do some āpreparation workā (i.e. trying to isolate the issue or build a Minimal Example), we have better chances.
PS:
For example, inside the whole āevalā stuff (we have 3 of them), remove everything but the obligatory one(s). If in the process of doing that you notice that the issue has went away, you have made a major leap towards a working script.