Re: Delay x return, how reliable, fast or slow is AppleScript?
Re: Delay x return, how reliable, fast or slow is AppleScript?
- Subject: Re: Delay x return, how reliable, fast or slow is AppleScript?
- From: Jon Pugh <email@hidden>
- Date: Wed, 15 Dec 2004 08:28:15 -0800
At 11:54 AM -0200 12/15/04, Bernardo Hoehl wrote:
>1) Since applescript is a high level language, when compared to "C", How fast can the system handle delay statements? How precise or reliable can be my Applescript app?
>
>2) What is the real difference between "delay" and "return" on a stay open app's loop?
>
>3) If I don't declare a "delay" in a loop? How much time should I expect applescript to delay just after it has executed the last line of the loop and start executing the first line again?
First off, you certainly do need an explanation, as these are not really relevant questions.
AppleScript scripts, like all computer programs, take time to run. Some of these time consuming operations can simply be consuming time, like the delay command. Others can be performing IO operations with stepper motors, or adding numbers together (an altogether too common occurrence). AppleScript loops operate in this realm too, and as such don't delay at all; they merely take some time to loop. This time is theoretically measurable, but there are issues doing any real time operations in AppleScript because of the undocumented implementation details.
Additionally, as Doug mentioned, you'll need a scriptable app, but let's leave that for the moment.
The primary reason for the difference between using the idle loop and a delay loop is the way you interact with the OS. In the delay loop, the OS calls your run handler and you do a loop, calling the delay scripting addition over and over again, along with other work, we hope. In the idle handler case, the OS calls your idle handler, it does the aforementioned "other work" and returns the number of seconds later it would like to be called again. The OS goes off and runs something else, and then returns with another idle message.
So, in the delay case you are sucking CPU time from the system, while in the idle case you are allowing the OS to feed you time.
Mmmmm, time.
Jon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden