Quirk coercing aliases to strings
Quirk coercing aliases to strings
- Subject: Quirk coercing aliases to strings
- From: Brennan <email@hidden>
- Date: Fri, 31 Aug 2001 02:16:19 +0200
I just discovered this:
set theFile to (choose file)
set n to "test"
set newPath to file ((theFile as string) & ":" & n)
Let's suppose you choose file "Macintosh HD:A Folder:A File"
The result of these three lines will be
"Macintosh HD:A Folder:test"
rather than
"Macintosh HD:A Folder:A File:test"
which is more what I would have expected. Actually, I would have expected an error for treating 'A File' as a folder.
It looks as though the ":" is doing a 'level up' in the file structure, like UNIX's ../
This can be confirmed by
set newPath to file ((theFile as string) & "::" & n)
Which will return
"Macintosh HD:test"
More colons will take you further, if you have further to go.
Can anyone explain this to me? I'm not complaining. I think it's very useful, but I don't fully understand what's happening.
'file' appears to be behaving in some special way here.
Try this version to see it even more clearly:
set theFile to (choose file)
set n to "test"
set str to (theFile as string)
set nn to (str & ":" & n)
log nn
set ePath to file nn