• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Interesting?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Photoshop action script
  • Next by Date: Re: Photoshop action script
  • Previous by thread: Re: Interesting?
  • Next by thread: Re: Open source movement for osax writers? (was Re: Scripting Additions: Embracing the Horror of Unix
  • Index(es):
    • Date
    • Thread