Language Guide

CHAPTER 9
Script Objects
278 Inheritance and Delegation
The following script includes two script object definitions similar to those
shown in Figure 9-1 on page 273. The first, Elizabeth, works just like the
script John in the figure. The second, ChildOfElizabeth, includes a handler
with a Continue statement that is not included in the child script object
(Simple) shown in the figure.
script Elizabeth
property HowManyTimes : 0
to sayHello to someone
set HowManyTimes to HowManyTimes + 1
return "Hello " & someone
end sayHello
end script
script ChildOfElizabeth
property parent : Elizabeth
on sayHello to someone
if my HowManyTimes > 3 then
return "No, I'm tired of saying hello."
else
continue sayHello to someone
end if
end sayHello
end script
In the preceding example, the handler defined by ChildOfElizabeth for the
sayHello command checks the value of the HowManyTimes property each
time the handler is run. If the value is greater than 3, ChildOfElizabeth
returns a message refusing to say hello. Otherwise, ChildOfElizabeth calls
the sayHello handler in the parent script object (Elizabeth), which returns
the standard hello message. The word someone in the Continue statement is a
parameter variable. It indicates that the parameter received with the original
sayHello command will be passed to the handler in the parent script.