Re: (no subject)
Re: (no subject)
- Subject: Re: (no subject)
- From: Chris Nebel <email@hidden>
- Date: Thu, 16 Nov 2000 21:04:42 -0800
- Organization: Apple Computer, Inc.
"Goodman, Steve" wrote:
>
> Is there any way to handle the error that crops up so that the
>
> repeat loop handles the error then simply goes on to try the next
>
> item in the list for existence and so on, for each item in the list?
>
>
Looks as though you need an "Exit repeat"..see below
>
>
Repeat with i from 1 to FileCount
>
Try
>
your stuff here
>
on error
>
exit repeat
>
end try
>
end repeat
I think that's the reverse of what jc was asking for, but it's on the right
track. Try...on error statements let you catch errors; what you do with them
after that is the interesting part. Steve's example will exit the loop cleanly
if any errors occur, but remaining items won't get processed. If you want to
ignore the error completely, don't do anything in the "on error" part, like
this:
repeat ...
try
<your stuff here>
on error
-- got an error, but we don't care.
end try
end repeat
Now errors will simply be ignored, and the loop will continue as if nothing
happened. Try statements are covered in detail in chapter 7 of the AppleScript
Language Guide.
--Chris Nebel
AppleScript Engineering