Re: Making a script stop executing using a library function
Re: Making a script stop executing using a library function
- Subject: Re: Making a script stop executing using a library function
- From: Nigel Garvey <email@hidden>
- Date: Mon, 13 Sep 2004 00:59:10 +0100
(Resent, as it hasn't appeared in any of the eleven digests I've received
so far this evening.)
Graff wrote on Fri, 10 Sep 2004 10:08:03 -0400:
>Just catch the error and throw it again. Error -128 will cause the
>calling script to quit unless it, in turn, catches it and handles it:
>----
>on display_text_dialog(dialogText)
> try
> tell application "Finder"
> set dialogResults to display dialog dialogText default answer ""
> end tell
> on error errMsg number errnum
> if errnum is -128 then
> -- If user canceled return something that
> -- will tell the script to stop executing
> error number -128
> else
> error errMsg
> end if
> end try
> return text returned of dialogResults
>end display_text_dialog
An individual error can be trapped with less code by specifying it in the
'on error' line:
on display_text_dialog(dialogText)
try
tell application (path to frontmost application as string)
set dialogResults to display dialog dialogText default answer ""
end tell
on error number -128 -- other errors not trapped
error number -128
end try
return text returned of dialogResults
end display_text_dialog
In this particular case, of course, it's simpler just not to use the
'try' block. :-)
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden