Re: Writing To A File
Re: Writing To A File
- Subject: Re: Writing To A File
- From: Walter Ian Kaye <email@hidden>
- Date: Tue, 30 Sep 2003 10:29:40 -0700
At 11:42a -0400 09/30/2003, Paul Skinner didst inscribe upon an
electronic papyrus:
On Tuesday, September 30, 2003, at 09:20 AM, Steve Mills wrote:
Yes, I know it's a standard addition. I was illustrating what not
to do. As for how bulletproof these commands are, I disagree. Run
this twice:
tell application "Finder"
set rn to open for access "Gort:Users:sjmills:Desktop:testblah"
with write permission
write "bob" to rn
close access rn
end tell
One the 2nd run, I get "Finder got an error: Duplicate file name.
some object". Take out the Finder targeting and I get "Duplicate
file name. Gort:Users:sjmills:Desktop:testblah".
Now add the class "file" before the pathname and it works.
Of course it works. That's how it was designed to work.
Clearly, it's a bug that it doesn't work a 2nd time if you pass a
pathname string.
Undefined behavior is not a bug; it's simply undefined behavior.
If you can't fly the Space Shuttle without error, is that a bug in you?
THIS is the problem I always have,
"Doc, it hurts when I do that."
"Then don't do that."
and it's not obvious that I have to remember to type "file" in front of it,
I guess you don't understand what a 'file reference' is.
(Hint: it is NOT a pathname. Never was.)
because almost every other app or command I regularly use that
takes a file reference works no matter what when I pass a pathname
string instead of a file or alias.
"I tested my Web page in Netscape. Whaddaya mean it doesn't work your browser?
RFC 1866? Whassat? It works in Netscape, so I must have done it right."
If other apps and commands are written to be smart enough to always
accept a string, then these commands should be too.
The commands expect you to be smart enough to RTFM first.
I mean, if you're going to do the programming yourself rather than
hiring someone else to do it, then there are certain things you
cannot skip without consequence. You experienced a consequence.
Surprise!
The dictionary is clear...
write: Write data to a file that was opened for access with write
permission (defined in: StandardAdditions.osax)
write anything -- the data to write to the file
[for double integer] -- the number of bytes to write; if not
specified, write all the data provided
[starting at double integer] -- start writing at this position
in the file
to anything -- the reference number or alias or file reference
of the file to write to
[as type class] -- how to write the data: as text, data, list, etc.
'write' doesn't accept paths at all.
Yup.
Steve, can you produce any Apple documentation stating that a
pathname is an acceptable substitute for a file reference? (I think I
can guarantee that you won't find any, so unless you have a lot of
time to waste...)
-boo
suddenly feeling sorry for the documentation writers who probably wonder
why they bothered writing it if people aren't reading it.
_______________________________________________
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.