Re: Quit Handler... What Am I Missing Here?
Re: Quit Handler... What Am I Missing Here?
- Subject: Re: Quit Handler... What Am I Missing Here?
- From: Luther Fuller <email@hidden>
- Date: Wed, 11 May 2011 19:08:34 -0500
On May 11, 2011, at 6:36 PM, S. J. Cunningham wrote:
> -- Simple quit test
>
> on run {}
> repeat while (true)
> end repeat
> display dialog "Whoops! Statement following quit in run handler"
> end run
>
> on quit {}
> continue quit
> end quit
'quit' does not do that! This script will run forever. (Fortunately there is 'Force Quit')
You must write some condition in the loop that will exit the loop ...
on run
repeat
delay 1
if <some_contition> then exit repeat -- or return
--
-- do stuff here
--
end repeat
end run
The 'delay 1' is there for two good reasons:
1. Not putting it there wastes cpu time ... your application becomes a cpu hog.
2. About 6 or 8 months ago, while doing some temperature tests, I found that a 'repeat' loop
without a 'delay' will cause (perhaps dangerous) over-heating.
If you wish to "call" the 'quit' handler from the 'run' handler, simply use 'return'.
_______________________________________________
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