Re: when quit is not quit
Re: when quit is not quit
- Subject: Re: when quit is not quit
- From: "Donald S. Hall" <email@hidden>
- Date: Sat, 03 Nov 2001 22:26:17 -0700
Jon,
Thanks for the reply. Could you elaborate on the following:
>
However, it's not an operation that quits immediately. It just tells the
>
applet shell to quit the next time AppleScript returns, since it is the
>
program calling OSAExecute or whatever and it can't quit until AppleScript
>
returns.
I am not sure what "the next time AppleScript returns" means exactly. Is
there anyway to force this to happen?
I ran your sample script below. I added a display dialog after quit in it as
indicated, and got the same result as for my own test script. (Note: In my
actual script, my handleError handler is called in a try/error block after
an error is thrown. My test script was only meant to demonstrate the slow
quit feature.) I am actually trying to avoid some data being written by my
script into a file after the quit command. I guess I will have to think of
some other way to do this.
This reminds me of my old MG Midget many years ago that used to "diesel"
along after the ignition was switched off.
Don
>
At 12:35 AM -0700 11/2/2001, Don and/or Judi Hall wrote:
>
> Why does the dialog "returned from handleError" appear even though this
>
> handler has a quit statement in it in the test script below?
>
>
Because quit is a message that the applet shell sends you when someone quits,
>
not a command to quit right now.
>
>
>
> Is there any way to get around this? I do not want my script to continue
>
> executing statements after the call to quit in handleError.
>
>
Then use real errors.
>
>
>
> -- quit test --
>
> -- save this as a stay open application and run from Finder
>
>
>
> on run
>
> set errMsg to "test message"
>
> set errNum to -1
>
> handleError(errMsg, errNum)
>
> display dialog "returned from handleError" buttons {"OK"} default
>
> button 1
>
> beep
>
> delay 1
>
> end run
>
>
>
> -- error handler --------------------------------------------------------
>
> to handleError(errMsg, errNum)
>
> activate me
>
> beep
>
> display dialog "error number " & errNum & ":" & return & errMsg &
>
> return ,
>
> buttons {"Quit"} default button "Quit" with icon stop
>
> quit
>
> end handleError
>
>
Try this instead:
>
>
on run
>
try
>
errorThrower("test message", -1)
>
beep
>
display dialog "No way, eh?"
>
delay 1
>
on error m number n
>
beep
>
activate
>
display dialog ("error number " & n & ":" & return & m & return) buttons
>
"Quit" default button "Quit" with icon stop
>
quit -- forgot this part
display dialog "after quit" <<<<<<<<<<<<<<< added line
>
end try
>
end run
>
>
-- error thrower --------------------------------------------------------
>
to errorThrower(errMsg, errNum)
>
error errMsg number errNum
>
end errorThrower
>
>
There you go, Don and/or Judi.
>
>
Jon
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.theboss.net/appsmore
email@hidden