Helpers
SenseTalk objects do not need to stand on their own. They can be helped by other objects that supply some or all of their behavior. For example, if you create a person object which has a handler to calculate the person’s age based on their birth date, that person object could be used as a helper for other objects, enabling them to also perform the age calculation without needing their own handler for that purpose.
Here is a sample script for an object which is helped by two other objects, named Rex and Sue:
sayHello -- let's start out by being friendly!
properties
helpers: [Rex, Sue],
birthdate: "May 14, 1942",
end properties
on sayHello
put "Greetings! My age is " & calculateAge()
end sayHello
This object’s sayHello
handler calls a function named calculateAge
. When the sayHello
handler is called, it will call calculateAge()
. This object doesn’t have a calculateAge function handler, but if one of its helpers, say Rex, does have such a function handler, that handler will be run on behalf of this object, to calculate the age.