Re: Writing to a file
Re: Writing to a file
- Subject: Re: Writing to a file
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 14 Jul 2002 13:25:52 -0700
On 7/14/02 1:12 PM, "JP Kelly" <email@hidden> wrote:
>
> You will get an error if you haven't closed access first. Are you saying you
>
> get an error even after closing access? you can't open for access with write
>
> permission if it's already open with write permission. Just write again
>
> while it's open, or close access first, then open again.
>
>
Well it is working now but I am not sure what I was doing wrong. (hate that)
>
Just so I am clear on this, to close the file do I want to use
>
>
close access file "Users:jpkelly:Library:Application Support:mover.prefs"
>
>
Or
>
>
close access fileRef
>
>
Or both?
>
>
I'm sure this is really basic, obviously I am quite a newbie.
Either will work, but close access fileRef is better. This is why:
You can open for access innumerable times just to read a file, but just once
at a time to write to it. So if several instances are open in memory,
close access file "Users:jpkelly:Library:Application
Support:mover.prefs"
will close just the last reference number, which may have been a reading
reference, still leaving the writing reference open and unavailable. You'll
go on erroring when you try to write if that's the case. What with all your
attempts, you probably had some extra instances open.
If you've lost track of the reference number, you can as a last resort do
this:
repeat
close access file "Users:jpkelly:Library:Application
Support:mover.prefs"
end repeat
When it has closed every instance, including the writing instance, it will
error:
"File file "Users:jpkelly:Library:Application Support:mover.prefs" was
not open"
[Don't ask me why it says "File file" twice. i don't know. ;-)]
But at least you know all instances are now closed. Since it's messy, it's
better just to get used to close access fileRef every time.
--
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.