Chapter 12. References


References are an important feature of AppleScript, and many values that you'll encounter using AppleScript will be references. A reference is a special type of data. It isn't the actual data; it's more like a pointer to the data. But it isn't a pointer, either; if you're used to pointers or indirect addressing from some other computer language, a reference is something else again. Remember, AppleScript is all about communicating with scriptable applications. In replying to a communication, the scriptable application might hand you a reference. In this context, a reference is a very powerful thing; it's like an Apple event primed and ready to communicate with an object in that application's world. A reference can be a great convenience, or it can be a danger: if you're not careful, you can send that Apple event and tell that scriptable application to do something you never intended. Unfortunately, AppleScript goes to some lengths to make it difficult for you to know that you've got a reference in the first place! This chapter explains what references are and how to know when you've got one. It also shows how to make a reference deliberately, and how to do some powerful things with references.

The phrase "by reference," as in "Set by Reference" in Chapter 7 and "Pass by Reference" in Chapter 9, is not what this chapter is about. When you pass a list "by reference" as a parameter to a handler, you do not pass a reference; you pass a list in a certain way. To make things even more complicated, we'll talk about passing a reference as a way to simulate passing by reference! The identity of the terminology is unfortunate but unavoidable.





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

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