Re: path to as string
Re: path to as string
- Subject: Re: path to as string
- From: has <email@hidden>
- Date: Sat, 25 Jun 2005 23:37:16 +0100
Matt Neuburg wrote:
>path to desktop as string
>(path to desktop) as string
>
>The results look the same, usually, but they are not.
This shouldn't matter: AppleScript hides the details precisely because/so users don't have to/need to worry about it. [1]
>I wonder whether this is wise behavior.
Since it's obsolete functionality that folk shouldn't be using anyway, its 'wisdom' - or lack thereof - is pretty much irrelevant.
BTW, I'd also discourage using 'path to ... as Unicode text', except in those few situations where HFS path strings are absolutely required. It's better to work with POSIX path strings (I believe HFS paths have some problems with uniqueness), as in [e.g.]:
POSIX path of (path to desktop) & "myfile.txt" -- [2]
This'll also keep you straight with the text types, BTW, since 'POSIX path of...' returns a Unicode text value. Though you still have to be careful when turning the path string back into a file object; I've noticed AppleScript errors when coercing a POSIX path string containing some non-English characters to a POSIX file object, although so far I've not had any problems with using the path string in a POSIX path specifier. [3]
>I have to admit I find this situation confusing.
Welcome to AppleScript; you must be new round here. <ducks> ;)
has
[1] At least in principle, anyway. In practice, of course, AppleScript abstractions have a history of springing leaks all over the place, forcing users to figure out these details so they can unscrew the problems such leaks inadvertently cause.
[2] Though even this code makes at least one potentially unsafe assumption, in that it assumes that the path returned by 'POSIX path of...' is guaranteed to end with a slash. Ideally one would use a library/osax/FBA command to assemble paths safely (e.g. see the join function in Python's os.path module).
[3] These days, the only AppleScript data types I trust with any real degree of confidence are booleans and records; the rest are a bit of a crapshoot. All you can do is go with the most reliable [or rather, least knowingly buggy] techniques you're aware of, and cross your fingers that those don't break as well at some point.
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden