• 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: Coerce String to Handler?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce String to Handler?


  • Subject: Re: Coerce String to Handler?
  • From: Timothy Bates <email@hidden>
  • Date: Sat, 14 Apr 2001 14:06:56 +1000

sorry, AppleScript does not support calling variables by contents (where you
can set the contents of a variable to the name of a second variable and then
call that second variable (in your case a handler) using the contents of the
first. There may be a kludge where you can set x to your handler as a
string, and then run x (which will compile the string into a script on the
fly), but this will be slow.

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

On 14/04/2001 12:53 AM, "Ehsan Saffari" <email@hidden> wrote:
> Is it possible to coerce a string to a handler name
> so the handler can be executed?
>
> set x to "iac"
> my handler x()
> --> Can't make "iac" into a handler.
>
> on iac()
> beep
> end iac

Dr Timothy Bates <mailto:email@hidden>
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University
Ph 61 (2) 9850 8623
Fx 61 (2) 9850 6059


  • Follow-Ups:
    • Re: Coerce String to Handler?
      • From: "M.S.R.F. Schonewille" <email@hidden>
    • Re: Coerce String to Handler?
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: AppleScript 1.6 issues
  • Next by Date: Re: AppleScript 1.6 issues
  • Previous by thread: Coerce String to Handler?
  • Next by thread: Re: Coerce String to Handler?
  • Index(es):
    • Date
    • Thread