• 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: Handlers in a variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handlers in a variable


  • Subject: Re: Handlers in a variable
  • From: Nigel Garvey <email@hidden>
  • Date: Sat, 16 Jan 2016 12:42:21 +0000

"Mark J. Reed" wrote on Fri, 15 Jan 2016 22:19:42 -0500:

>    to call(aHandler, aValue)
>       aHandler(aValue)
>    end
>
>    call(double, 4)
>
>    error "«script» doesn’t understand the “aHandler” message." number
>-1708 from «script»

Hi Mark.

The handler has to be transferred to a non-local variable and called
with that. eg.:

  to call(aHandler, aValue)
    global h

    set h to aHandler
    h(aValue)
  end call

Or avoiding a global:

  to call(aHandler, aValue)
    script o
      property h : aHandler
    end script

    o's h(aValue)
  end call

NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Prev by Date: Re: [ASOC] returning by reference, and converting script objects to descriptors?
  • Next by Date: Re: Handlers in a variable
  • Previous by thread: Re: Handlers in a variable
  • Next by thread: Re: Handlers in a variable
  • Index(es):
    • Date
    • Thread