Re: try...on error...no error?
Re: try...on error...no error?
- Subject: Re: try...on error...no error?
- From: Steve Roy <email@hidden>
- Date: Fri, 12 Dec 2003 16:11:11 -0500
Michael Terry <email@hidden> wrote:
>
tell app "Finder" to try
>
set srcFile to file "blah" of folder "blah" of disk "blah"
>
set destFold to folder "blah" of disk "blah"
>
open for access (srcFile as unicode text) write permission true
>
close access result
>
copy theFile to destFold
>
on error
>
-- etc
>
end try
I have a comment that has nothing to do with the subject of this thread, but I
thought would be good to point out.
When opening a file, you should make sure to close it in the error handler in
case something wrong occurs when trying to read/write the file.
try
set theFileRef to missing value
set theFileRef to open for access ...
doSomethingWithTheFile(theFileRef) -- Could produce an error
close access theFileRef
on error
if theFileRef is not missing value then
close access theFileRef
end if
end try
Steve
--
Steve Roy <email@hidden>
Personal homepage: <
http://homepage.mac.com/sroy>
Projects homepage: <
http://www.roydesign.net>
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.