Allowed coercion
Syntaxset theRef to a reference to (the name of file 1 of desktop) DescriptionThe reference class points to an object or value. In the syntax example, theRef points to the name of file 1 on the desktop, no matter which file becomes the first file on the desktop over time. In other words, the value of this reference can change. If you just set theRef to name of file 1 of desktop as opposed to a reference to name of file 1 of desktop, then theRef would contain a string (such as "myfile.txt") rather than a reference to the name. The next time you referred to the variable theRef in the script, it would still have the string value "myfile.txt," even if this file were no longer file 1 of desktop (i.e., it might now be file 2 or file 3 because the desktop files got changed around). A reference to the name of file 1, however, would continue to provide the name of the desktop's first file, even if that file had changed since the theRef variable was initialized. ExamplesTo set a variable to a reference class, you use the a reference to operator, or a ref to for short. Some references, such as Finder references to files or folders, can be coerced to strings: tell application "Finder" set theRef to a reference to the name of file 1 get theRef as string -- returns "filename.txt" end tell |