Language Guide

CHAPTER 8
Handlers
Subroutine Denitions and Calls 239
A parameter pattern can be much more complex than a single list. The handler
in the next example takes two numbers and a record whose properties include
a list of bounds and displays a dialog box summarizing some of that
information:
on hello(a, b, {length:l, bounds:{x, y, w, h}, name:n})
set q to a b
set response to "Hello " & n & ", you are " & l & ¬
" inches tall and occupy position (" & x & ", " & y & ")."
display dialog response
end hello
set thing to {bounds:{1, 2, 4, 5}, name:"George", length:72}
hello (2, 3, thing)
As you can see from this example, a call to a subroutine with patterned parame-
ters can include parameters that aren’t literals, as long as they evaluate to the
appropriate pattern. Similarly, the properties of a record passed to a subroutine
with patterned parameters don’t have to be given in the same order in which
they are given in the subroutine’s definition, as long as all the properties
required to fit the pattern are present.
The Return Statement 8
A Return statement allows you to stop execution of a handler before all its
statements are executed and to obtain a value. Many of the preceding examples
in this chapter use Return statements.
Return 8
A Return statement exits a handler and returns a value. When AppleScript
executes a Return statement, it stops handler execution and resumes execution