Language Guide

CHAPTER 4
Commands
116 Command Denitions
Patterns set with the Set command can also be more complex. Here are
some examples:
set x to {8, 94133, {firstName:"John", lastName:"Chapman"}}
set {p, q, r} to x
(* now p, q, and r have these values:
p = 8
q = 94133
r = {firstName:"John", lastName:"Chapman"} *)
tell front document of application "Scriptable Text Editor"
set {word 1, word 2} to ¬
{firstName of item 3 of x, lastName of item 3 of x}
end tell
--now word 1 = "John" and word 2 = "Chapman"
set {p, q, {lastName:r}} to x
(* now p, q, and r have these values: p = 8
q = 94133
r = "Chapman" *)
As the last example demonstrates, the properties of a record need not be given
in the same order and need not all be used when you set a pattern to a pattern,
as long as the patterns match.
The use of the Set command with patterns is similar to the use of patterned
parameters with subroutines, which is described in “Subroutines With
Positional Parameters,” beginning on page 235.