Re: Loop Until Quit
Re: Loop Until Quit
- Subject: Re: Loop Until Quit
- From: Brian Johnson <email@hidden>
- Date: Wed, 14 Nov 2007 17:09:23 -0800 (PST)
On Wed, 14 Nov 2007, Marconi wrote:
What's the best construct to simply loop continuously until the script (app)
is quit. That is, upon launch:
Initialize some stuff
repeat
do something
delay xx
end repeat
There is no condition to check to see if the repeat is due. It's desired that
it repeat as long as the script.app is running.
The script.app could either be quit from Finder or maybe it could put up a
dialog and while idle, check to see if the dialog's Quit button is clicked.
Is it OK to repeat unconditionally or should I:
repeat while true -- always true!
do something
delay xx
end repeat
Or should I use some other looping construct?
Marconi,
A running script will receive "idle" events from the system scheduler, you
can use these, returning the desired delta-time to the next idle event
(note, there is no absolute guarantee that this time will be honored
precisely, as other events may intervene, but it will be close...). So
something like this, as script app, usually does the trick.
on idle
-- do something
return interval -- integer seconds to next idle event
end idle
-brian johnson, dept of architecture, university of washington, seattle
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden