Language Guide

CHAPTER 8
Handlers
238 Subroutine Denitions and Calls
Examples of Subroutines With Positional Parameters 8
Here is a subroutine that returns the minimum value of a pair of values
followed by an example of how to call the subroutine.
on minimumValue(x, y)
if x y then
return x
else
return y
end if
end minimumValue
minimumValue(21, 40000)
You can also define a subroutine whose positional parameters define a pattern
to match when calling the subroutine. For example, the subroutine that follows
takes a single parameter whose pattern consists of a list of two items in a list.
on point({x, y})
display dialog ("x = " & x & ", y = " & y)
end point
set mypoint to {3, 8}
point(mypoint)