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: Nigel Garvey <email@hidden>
- Date: Thu, 12 May 2011 12:03:33 +0100
"S. J. Cunningham" wrote on Wed, 11 May 2011 11:58:37 -0400:
>OS X 10.6.7. I want to run a script as an application but I can't seem to
>get the quit handler to quit. Seems to me it used to work this way but
>maybe my memory is faulty. Or maybe Snow Leopard changed something.
>Anyway, here is the sample script I am running. I get the same behavior
>with an implicit run handler. Help appreciated.
>
>Thanks.
>
>(*
> Quit Handler Example Case 1: Explicit run handler
>
> - Works as expected when run from Script Menu as either
> Compiled Data Fork or Compiled Bundle
> - Continue quit ignored when run as an Application Bundle
> either from Finder or Script Menu.
>*)
>
>on run {}
> display dialog "Quit Handler Example Case 1: explicit run handler"
> display dialog "Calling quit handler"
> quit
> display dialog "Whoops! Statement following quit in run handler"
>end run
The 'quit' command tells the application running the script to quit when
it's finished what it's doing — ie. running the script. Since you have
another command after the 'quit', that command will be executed before
the application actually does quit.
If you want to stop a script on the spot, use 'error number -128'
instead. If it's running as a non stay-open application, it'll quit then
of it's own accord.
>on quit {}
> display dialog "quit handler entered"
> try
> set dialogAnswer to display dialog ¬
> "Continue quit?" buttons {"Yes", "No", "Cancel"} ¬
> default button "Yes"
> if button returned of dialogAnswer is "Yes" then
> display dialog "continuing quit"
> continue quit
> display dialog "Statement following continue quit"
> else
> -- your code for No goes here
> end if
> on error number -128 -- userCanceledErr
> -- your code for Cancel goes here
> end try
> display dialog "Exiting quit handler"
>end quit
Similarly here you have two 'display dialog' commands after 'continue
quit', so these must be executed before the application can quit.
NG
_______________________________________________
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