• 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: "Stockly, Ed" <email@hidden>
  • Date: Wed, 20 Jan 2016 01:10:36 +0000
  • Thread-topic: Handlers in a variable

Not sure how a handler in a variable is on a different level of sanity or insanity than an ordinary handler. 

Seems as if it's more useful in a global or a property, if you actually want to use it outside the handler you set in. 

In my script I used it for a file reference. The variable would be set to one of several handlers, depending on some condition.  

It needs to be global in scope in this scenario. (uncomment the property to make it work). 
---------------

--property someHandler : ""


on double(aNumber)

return aNumber * 2

end double

on call(someHandler, aValue)

someHandler(aValue)

end call

on MyHandler()

someHandler(4)

call(double, 4)

end MyHandler

on FirstHander()

set aValue to "3"

set someHandler to double

someHandler(4) -- fails here if someHandler is not a property

end FirstHander

on run

set someHandler to ""

FirstHander()

someHandler(4)

call(double, 4)

MyHandler()

end run

 --------------
On 18/01/2016 20:04, has wrote:
Ed Stockly wrote:
This works.

Sure it does.[...]

Oops, my response was actually to Christopher's post ("No property required "), not Ed's (next level of insanity again).
 
 _______________________________________________
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

  • Follow-Ups:
    • Re: Handlers in a variable
      • From: has <email@hidden>
References: 
 >Re: Handlers in a variable (From: has <email@hidden>)
 >Re: Handlers in a variable (From: has <email@hidden>)

  • Prev by Date: Re: Script Library Search Order
  • 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