Re: How to exit ?
Re: How to exit ?
- Subject: Re: How to exit ?
- From: Emmanuel <email@hidden>
- Date: Tue, 28 Aug 2001 14:32:29 +0200
At 11:35 +0200 28/08/01, Jan Erik Mostrvm wrote:
>
>
In HyperTalk there was a command "exit to HyperCard" that would allow me
>
to jump
>
out of any script no matter how deep the call chain was, directly without
>
returning to any previous handler.
>
>
What is the recommended way of doing this in AppleScript?
"exit to HyperCard" exited ... to HyperCard. There is no such universal
underlying app with AppleScript.
If the script runs as an applet, then "quit" is the answer.
If the script runs from a different application, such as a script editor or
an app able to run scripts, then "quit" won't help much I'm afraid. In
which case you must build your own "exit" system. I would use "error number
-128" as the "exit" signal. Systematically trap errors, and systematically
propagate the "User cancelled" (number -128) error. Alternately, you can
trap just for that error.
-----------------
on WhateverRoutine()
try
-- script
-- to exit just trigger the error
if Things_Go_Bad then error number -128
on error number -128
error number -128
end
end
-----------------
It's not simple.
Emmanuel