Re: Behavior change in "open for access" from AS 1.6 to 1.8.3?
Re: Behavior change in "open for access" from AS 1.6 to 1.8.3?
- Subject: Re: Behavior change in "open for access" from AS 1.6 to 1.8.3?
- From: has <email@hidden>
- Date: Fri, 5 Jul 2002 10:12:22 +0100
Dan Feather wrote:
>
Dunno what else to blame it on, but since updating from AS 1.6 to 1.8.3,
>
I've found an error in one of my scripts that makes me wonder if I've
>
encountered a significant change in behavior for the "open for access"
>
command.
>
>
In a "try" block, I had the line (where thPath was a string):
>
--
>
set thRef to (open for access thPath without write permission)
>
--
>
>
When there was NOT such a file, the error number was -43, which I trapped
>
and the script continued, noting that the file in question did not exist
>
(which, in my case, meant there were no "to do" entries for a given day).
>
>
Since upgrading to 1.8.3, if the file doesn't exist, the same script line
>
returns a -39 error:
>
(*End of file error., -39*)
>
AND (here's the rub . . . ) it creates an empty file!
>
>
Is this a known (and intended) change?
The AS 1.6 Standard Additions dictionary states:
open for access alias -- the file to open for access. If this is a
file specification of a file that does not exist, a new file is created.
I think if you were getting some other behaviour under 1.6 then something
was odd with your system.
BTW, if I try your above code in Script Editor (AS1.6), I get an error:
"Can't make [string] into a file specification." So it looks like you might
have some third-party coercions working in there as well. (e.g. If I try it
in Smile instead of SE it does execute; Smile seems to perform a built-in
coercion of its own.) At a guess, the -43 was being thrown when something
attempted to implicitly coerce your string to an alias.
The -39 error comes from reading the empty file (on some/all AS versions?)
- I'm sure there was something mentioned about this in the 1.8.3 release
notes.
The correct approach would be to test explicitly for the file's existence,
e.g. with the Finder's 'exist' command, beforehand. (Although it does seem
that for 'open for access' to be able to create a new file when it doesn't
have write access is a bit perverse.)
HTH
has
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
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.