• 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: Christopher Stone <email@hidden>
  • Date: Wed, 20 Jan 2016 12:34:21 -0600

On Jan 19, 2016, at 19:32, Stockly, Ed <email@hidden> wrote:
The version above works only if someHandler is a property. If you note out that line it fails.
______________________________________________________________________

It works fine if you declare someHandler as a global variable.

I think this demonstrates scope more clearly than using a Property (provided you don't need it to be a Property).

--
Take Care,
Chris

------------------------------------------------------------
global someHandler
------------------------------------------------------------

DoFirstHander()
someHandler(4)
call(double, 4)
DoMyHandler()

------------------------------------------------------------
on double(aNumber)
  return aNumber * 2
end double
------------------------------------------------------------
on call(someHandler, aValue)
  someHandler(aValue)
end call
------------------------------------------------------------
on DoMyHandler()
  someHandler(4)
  call(double, 4)
end DoMyHandler
------------------------------------------------------------
on DoFirstHander()
  set aValue to "3"
  set someHandler to double
  someHandler(4) -- Fails here if someHandler is not global.
end DoFirstHander
------------------------------------------------------------

 _______________________________________________
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: Bernard Moreau <email@hidden>
References: 
 >Handlers in a variable (From: "Mark J. Reed" <email@hidden>)
 >Re: Handlers in a variable (From: Chris Page <email@hidden>)
 >Re: Handlers in a variable (From: "Stockly, Ed" <email@hidden>)
 >Re: Handlers in a variable (From: Chris Page <email@hidden>)
 >Re: Handlers in a variable (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: Security Update [Was: Re: Script Library Search Order]
  • Next by Date: Odd Speed Issue with choose folder
  • Previous by thread: Re: Handlers in a variable
  • Next by thread: Re: Handlers in a variable
  • Index(es):
    • Date
    • Thread