Re: Interesting?
Re: Interesting?
- Subject: Re: Interesting?
- From: has <email@hidden>
- Date: Sun, 3 Feb 2002 22:15:26 +0000
Victor Yee wrote:
>
I was hoping that I was able to store the handler in a list, similar to
>
storing
>
a script object, and somehow have it execute in some manner.
>
>
I wasn't thinking straight and missed the obvious.
I've made the same mistake myself. :)
What you're after is:
======================================================================
on jack(a)
display dialog "Jack says " & a
end jack
on jill(a)
display dialog "Jill says " & a
end jill
property handlerList : {jill, jack}
global theHander
on saySomething(someString)
repeat with eachItem in handlerList
set theHander to eachItem's contents
theHander(someString)
end repeat
end saySomething
saySomething("hello")
======================================================================
[i.e. 'jack()' is merely a call to a handler object; 'jack' is the object
itself.]
I used this in my strftimeLib to avoid the need for a really long
if..elseif... block (which would have slowed things down significantly) - I
could have wrapped each handler in its own script object, but this approach
used less lines of code.
HTH
has