Re: when quit is not quit
Re: when quit is not quit
- Subject: Re: when quit is not quit
- From: Jon Pugh <email@hidden>
- Date: Fri, 2 Nov 2001 21:12:21 -0800
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
end try
end run
-- error thrower --------------------------------------------------------
to errorThrower(errMsg, errNum)
error errMsg number errNum
end errorThrower
There you go, Don and/or Judi.
Jon