• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Quirk coercing aliases to strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Scripting Newbie
  • Next by Date: Re: Getting running status of an application
  • Previous by thread: Re: Getting running status of an application
  • Next by thread: Re: Quirk coercing aliases to strings
  • Index(es):
    • Date
    • Thread