Re: Reading a file in the user's home Documents
Re: Reading a file in the user's home Documents
- Subject: Re: Reading a file in the user's home Documents
- From: Dave Stewart <email@hidden>
- Date: Fri, 12 Sep 2003 10:00:39 -0700
On Thursday, September 11, 2003, at 07:15 PM, Paul Berkowitz saved me
by offering:
After a half an hour trying to figure out the syntax of:
set theUserCodePath to (((path to current user folder) as text) &
"Documents:updateScriptKey" as POSIX file)
so I can
set theFileToRead to open for access theUserCodePath
I give up.
Is there any particular reason why you're trying to get a POSIX file?
(Let
alone why you've arranged your parentheses so that only the last bit
-the
bit of the path from "Documents" on - has that unusual criterion
applied to
it.)
Honesty is the best policy, right? I was modeling this after the
tutorial example in /Documents/Examples/AppleScript Studio/Plain Text
Editor and in that example they open the file as a POSIX file. I've
seen that on occasion on the list here, so it seemed like the thing to
do. The parentheses are entirely my fault, though (it seemed to make
sense at the time).
set theFileToRead to alias ((path to "docs" as Unicode text) &
"updateScriptKey" )
The magical incantation that I desperately needed, many many thanks!
AppleScript uses colon-delimited path names. You only need POSIX
files for
'do shell script' (i.e. Unix operations) and AppleScript Studio (i.e.
Cocoa). And TextEdit, as mangled by a developer who didn't know
AppleScript.
Ah, that clears things up somewhat. I am doing a "do shell script" in
this script, but not in this section of code (this part is just reading
something from a file, the contents will be used in a do shell script
but I think I have that part worked out.)
Only
AppleScript can make this simple an operation so convoluted that I
have
to ask the list how to do it. Any other language and I would have
figured it out 29 minutes ago.
It _is_ simple. Why do you find it necessary to berate AppleScript for
your
own lack of knowledge? Try reading the AppleScript Language Guide to
learn
about AppleScript.
More honesty due here. Why did I find it "necessary"? Because I was
frustrated and it was the end of the day. Does that excuse me? No. Was
it "AppleScripts" fault? No. Should I have included that little
frustrated rant (did it belong in the post at all)? Lamentably, no. My
apologies for that, I should have known better than to vent like that
(read: stupid mistake). I should point out that I was looking at the
ASLG last night (and again this morning) but couldn't find anything
that was helpful in this situation (it's typically one of the first
places I look now when I'm lost, it usually gets me by. That and this
list, both through it's archives and the very helpful responses people
like you offer when I'm very stuck).
Either way, that doesn't excuse "the little rant that should not have
been" and for that I'm truly sorry.
Many thanks again! Also, allow me to extend thanks to Matthew Smith and
Walter Kaye, who also pointed out that the POSIX part wasn't needed and
in fact causing the problem.
Dave Stewart
Aqua-flo Supply (Goleta)
email@hidden
Be nice to other people; they outnumber you 5.6 billion to 1
_______________________________________________
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.