• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: try...on error...no error?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: try...on error...no error?


  • Subject: Re: try...on error...no error?
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 12 Dec 2003 14:01:11 -0800

On 12/12/03 1:11 PM, "Steve Roy" <email@hidden> wrote:

> 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

Or just:

try
set theFileRef to open for access ...
doSomethingWithTheFile(theFileRef) -- Could produce an error
close access theFileRef
on error
try
close access theFileRef
end try
end try

--
Paul Berkowitz
_______________________________________________
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.

  • Prev by Date: Re: Insert text into a document (beginners Question)
  • Next by Date: Re: Insert text into a document (beginners Question) Solved
  • Previous by thread: Re: try...on error...no error?
  • Next by thread: Quark conflicting properties
  • Index(es):
    • Date
    • Thread