Language Guide
CHAPTER 4
Commands
Command Definitions 115
EXAMPLES
You can use the Set command to set a variable to any value:
set x to 5
set myList to { 1, 2, "four" }
tell application "Scriptable Text Editor"
set x to word 1 of front document
end tell
These two statements are equivalent:
set x to 3
3 returning x
Similarly, the following examples are equivalent:
tell front document of application "Scriptable Text Editor"
set x to word 1
end tell
tell front document of application "Scriptable Text Editor"
word 1 returning x
end tell
In addition to setting a variable to a single value, you can set patterns of
variables to patterns of values. For example, this script sets a list of two
variables to the position of the front window.
tell application "Scriptable Text Editor"
set {x, y} to position of front window
end tell
Since the Scriptable Text Editor returns position of front window as a
list of two integers, the preceding example sets x to the first item in the list and
y to the second item.