Path to ... as string [was Re: Complete newbie]
Path to ... as string [was Re: Complete newbie]
- Subject: Path to ... as string [was Re: Complete newbie]
- From: Nigel Garvey <email@hidden>
- Date: Thu, 24 Apr 2003 20:47:44 +0100
John Delacour wrote on Wed, 23 Apr 2003 21:14:03 +0100:
>
At 7:57 pm +0200 23/4/03, Philippe GRUCHET wrote:
>
>
>Better is:
>
>
>
>------------------------------------
>
>tell application "TextEdit"
>
>activate
>
>open ":Users:imani08:Documents:Test" as alias
>
>end tell
>
>------------------------------------
>
>
>
>By this way, you'll never have to write the HD's name if you don't need to.
>
>
Far better is
>
>
"" & (path to "docs") & "filename" as file specification
>
>
That way it's not specific to any named user and the file doesn't
>
even have to exist.
Even better still is:
(path to "docs" as string) & "filename" as file specification
This way, 'path to' returns the "docs" path string directly, instead of
returning an alias which is then coerced to string by AppleScript and
concatenated to "". It's about 8.3 times as fast on my machine. (8.4 if I
change "docs" to 'At Ease documents folder'.)
The file should ideally exist if you're trying to open it in TextEdit.
;-) 'as file specification' used to be one of Jon's Coercions. Does it
work natively now?
I was fooling around with 'path to ... as string' earlier today and made
an interesting (if not particularly useful) discovery. If the folder
specified is within another that 'path to' knows about, its faster to get
the path to the outer folder as string and then concatenate the rest of
the path - if known. So:
(path to current user folder as string) & "Documents:"
... is slightly faster than:
path to "docs" as string
And:
(path to startup disk as string) & "Users:username:Documents:"
... is dramatically faster still.
As I said, not particularly useful, but interesting. :-)
NG
_______________________________________________
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.