Re: Closing Files That I Left Open
Re: Closing Files That I Left Open
- Subject: Re: Closing Files That I Left Open
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 02 Aug 2002 12:03:22 -0700
On 8/2/02 11:49 AM, "email@hidden" <email@hidden> wrote:
>
So I'm learning AppleScript
>
>
What I'm working on right now opens and writes files, reporting on what the
>
script is doing
>
>
But sometimes I get errors, and that means that the files don't get closed
>
properly.
>
>
So when I next try to open the file, I get an error that it's in use. I
>
know that I should be closing the file in my "on error" blocks, and I am,
>
but I'm still trying to find all of the times when I need to do that.
>
>
So my question is... how can I release the file from the previous run of
>
the script without a logout/login cycle? Does anyone know of any OSX
>
utilities that will let me do this?
You can close access by file path rather than by file reference number. You
might have to do it a few times if you also read it more than once. (You can
open or access with write permission only once at a time, but you can open
for access to read simultaneously as much as you want.) usually once is
enough.
set f to open for access file "HD:A Folder:New name" with write permission
-- a new file ref
do somethingWrong -- oops!
close access alias "HD:A Folder:New name" -- puts it OK again
--
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.