Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: catching multiple errors



At 11:15 AM -0700 6/23/06, Michelle Steiner wrote:
On Jun 23, 2006, at 10:55 AM, Jeremy Matthews wrote:

Does anyone have an example of applescript syntax for catching multiple errors?

For example, catch errors if people chose to cancel, or if a file wasn't there, or the preference was changed, etc...

Nested if-then statements within a try block.

try
	display dialog "enter the file name" default answer "text.txt"
on error msg number num
	if num is -1 then
		--do something
	else if num is 25 then
		--do something else
	else if num is -128 then
		--do yet another thing
	end if
end try

Now, you've got to find out what error numbers you're interested in. To that effect, willingly trigger the error and have the "try ... on error" structure display its number:


try
	alias "Macintosh HD:the:file:doesn't:exist"
on error number n
	display dialog "error number " & n -- will be -43, "File not found"
end

Emmanuel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >catching multiple errors (From: Jeremy Matthews <email@hidden>)
 >Re: catching multiple errors (From: Michelle Steiner <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.