• 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: equivalence of Reflection-Method Selector in AS-was Scripter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: equivalence of Reflection-Method Selector in AS-was Scripter


  • Subject: Re: equivalence of Reflection-Method Selector in AS-was Scripter
  • From: "Jason W. Bruce" <email@hidden>
  • Date: Thu, 16 Nov 2000 14:53:53 -0600

The following is a revision to a script I posted a few days ago which
displays a list of handlers in a script object and then executes the chosen
handler. It uses labeled parameters to accept run-time parameter input and
Richard23's method of reassigning handlers. It does not require the run
script command to execute the chosen handler. Although the design-wisdom of
Richard23's method has been questioned, I have to agree with Richard23 that
if implemented carefully the method of reassigning handlers is very powerful
and extends one's capabilities with the language. As the following method
still requires one to construct the list of handlers manually, I still would
like to know if anyone knows how to do this at run time -- that is, to ask a
script object to return its own handlers.

script HandlerPicker

to beep1 given foobar:x
beep x
end beep1

to beep2 given foobar:x
beep x
end beep2

to sing given foobar:x
display dialog x
end sing

to sing10()
beep 10
end sing10


set handlerlist to {beep1, beep2, sing, sing10}
set displaylist to {}
repeat with loopvariable in handlerlist
try
x of loopvariable
on error errorstring
set end of displaylist to word 6 of errorstring
end try
end repeat


choose from list displaylist
set userchoice to the result as text
display dialog "Please Enter Parameter For Handler " & userchoice default
answer ""
set inputparameter to text returned of the result

repeat with loopvariable from 1 to count items of displaylist
if item loopvariable of displaylist is userchoice then
set dummyhandler of me to (item loopvariable of handlerlist)
return dummyhandler of me given foobar:inputparameter
end if
end repeat

end script

to dummyhandler given foobar:x
end dummyhandler

tell HandlerPicker to run

Jason Bruce


  • Prev by Date: Re: Newbie plea
  • Next by Date: employment fo scripting wizard
  • Previous by thread: Resend: Re: Newbie plea
  • Next by thread: employment fo scripting wizard
  • Index(es):
    • Date
    • Thread