Section 11.12. Object String Specifier


11.12. Object String Specifier

For certain objects in the "real world" (that is, the real world inside the computer), AppleScript has a bootstrap problem. It needs a way to refer to these objects, yet they are not attributes of anything. In fact, they are the things that have attributes. So in order to talk about anything at all outside of the script, AppleScript must pull itself up by its bootstraps.

The solution is an object described using the name of the class followed by a string. It looks rather like an element specifier by name; but the object isn't an element of anything, and the string isn't exactly a name. There is no official term for this construct in Apple's documentation, so I call it an object string specifier . The main real-world objects for which object string specifiers are used are applications, files and aliases, and dates. Details appear in Chapter 13, but here are some examples.

Throughout this chapter I've constructed application targets using an object string specifier with the application class:

 tell application "BBEdit"

In the case of a file or an alias, the string is a pathname:

 get POSIX path of file "myDisk:myFile"

The string doesn't have to be a literal; a variable will work just as well:

 set f to "myDisk:myFile" get POSIX path of file f




AppleScript. The Definitive Guide
AppleScript: The Definitive Guide, 2nd Edition
ISBN: 0596102119
EAN: 2147483647
Year: 2006
Pages: 267
Authors: Matt Neuburg

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net