DekGenius.com
[ Team LiB ] Previous Section Next Section

10.9 Object String Specifier

Objects of certain classes can be constructed in code using the name of the class followed by a string. Formally, this 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 term for this construct in Apple's documentation, so I have coined the term object string specifier to denote it.

For example, AppleScript's built-in file class works this way; you can make a file object by using the word file followed by a string representing the pathname, as in the following code:

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 also uses an object string specifier to represent a file object when reporting it as a value:

set f to "myDisk:myFile"
a reference to file f
-- file "myDisk:myFile" of «script»

AppleScript's application class works the same way; that is why I have been using this form of address throughout this chapter:

tell application "BBEdit"

Built-in classes that use object string specifiers will be duly noted as doing so, in Chapter 13.

    [ Team LiB ] Previous Section Next Section