r/applescript • u/agrajag63 • Oct 30 '24
out-of-sequence execution in script?
I use an AppleScript (running directly from the Script Editor application) to control some apparatus-- it is a legacy system running macOS 10.9. The script talks to a couple of applications and loops until the "done" condition from one of the applications is reached. After that is code to tell an app to download the data.
Very occasionally the script will seem to execute lines from the script out of sequence. For example today it seemed to execute the "data download" section of code before the "done" condition had been reached.
Is it a thing that applescript can execute lines of a script out of order? If so, is there any way to strictly enforce execution order?
View all comments
Show parent comment
1
u/duquesne419 Oct 31 '24
Just giving this a quick look, sorry if I'm overlooking something.
I don't see where the variable "currentpass" is instantiated. If it is being set to a standard number, you might be able to predetermine the number of loops needed, and switch the problematic while loop to a discrete for loop. I tend to favor for loops because the downstream code matters less if you're always running a set number of loops. But if the counting on currentpass isn't standard then it may not matter. Just a thought for something to try.
Alternatively, can you force the download to wait 75 seconds instead of trying to calculate length? If you know you're going to be done in 60 seconds or less but having issues with an early exit, maybe keep the door closedpast 60?