Re: Coerce String to Handler Name?
Re: Coerce String to Handler Name?
- Subject: Re: Coerce String to Handler Name?
- From: Ehsan Saffari <email@hidden>
- Date: Sun, 15 Apr 2001 05:14:38 -0600
On 14/04/2001 17:20, Emmanuel, email@hidden wrote:
>
At 6:06 +0200 14/04/01, Timothy Bates wrote:
>
>
>If anyone at apple was keen, calling by name is a fantastic capability for a
>
>language, and is really essential for handling html forms which can have
>
>variable variables, if you get what I mean.
>
>
>
>a suitably verbose syntax could be
>
>
>
>
>
>my x as named variable
>
>
>
>or
>
>
>
>contents of x as variable
>
>
>
>set x to "iac"
>
>
>
>on iac()
>
> beep
>
>end iac
>
>
Not sure I understand. 'run script' does something like calling by name.
>
The matter here is more a matter of availability of the handler (the
>
question of the context). In applets (or, in the text windows of Smile),
>
which have permanent contexts, you can run:
>
>
----------------
>
on iac()
>
beep
>
end iac
>
>
run script("iac()")
>
----------------
>
>
Script Editor's windows may not run properly this script.
Neither does SMILE :) But I think "run script" is off the mark.
Dr. Bates got my drift() right away ;>
--I changed the subject line slightly to better reflect the question--
I'll explain further: The context is an applet, not any editor. The
Applet contains many handlers. They are called from outside the applet. A
simple open AE is sent to the applet from another application, then the
applet reads the name of an object in the calling application and chooses
which handler to invoke and what variables to read from the calling app
based on this object name, which is a string.
It would be most elegant if this string could be used to invoke the
required handler without first defining a huge nested if clause that goes
like : If x="a", my a(), else if x="b", my b(), ad nausem. This would
also make the calling app simple since calls to all handlers can be made
with ONE simple calling routine, not to mention maintenance of both sides
of this exchange.
Thanks for any insights.
cheers
ehsan