• 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: passing handler problems and a resolution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing handler problems and a resolution


  • Subject: Re: passing handler problems and a resolution
  • From: Axel Luttgens <email@hidden>
  • Date: Wed, 26 Jan 2011 18:10:49 +0100

Le 24 janv. 2011 à 18:41, Walter Bushell a écrit :

> I am trying to objectify my code by lists as objects that can be put into lists and then said lists around for processing. After much agony, I found that if I could call a passed handler if and only if the variable was global. Modest example follows:
> [...]
>
> Which shows that one has to call a passed handler from a global variable ("globalScratch" which is set to "w" in this case), or I suppose a property. Also the
> "	set xroutine to yroutine"
> line in the run handler apparently makes "xroutine" global or something extra special.

Hello Walter,

Indeed, it seems that in an expression such as

	somename(x, y, ...)

the name "somename" needs to be a top-level one for having a chance to be evaluated before the actual handler invocation occurs.
Never noticed the fact.

That said, you may avoid to declare "somename" as a global everywhere in your code; just declare as such where really needed, and be sure to use very specific names so as to avoid potential clashes; for example:

	on run
		zroutine({yroutine, 5, 7})
	end run

	to zroutine(myParameter)
		global zroutine_internal_param1
		local x, y
		set {zroutine_internal_param1, x, y} to myParameter
		zroutine_internal_param1(x, y)
	end zroutine

	to yroutine(x, y)
		return x + y
	end yroutine

HTH,
Axel

 _______________________________________________
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: passing handler problems and a resolution
      • From: Walter Bushell <email@hidden>
References: 
 >passing handler problems and a resolution (From: Walter Bushell <email@hidden>)

  • Prev by Date: Re: Is Image Disk Trash Empty?
  • Next by Date: Re: 'my' problem is your problem: it chokes without 'my'! BUG
  • Previous by thread: passing handler problems and a resolution
  • Next by thread: Re: passing handler problems and a resolution
  • Index(es):
    • Date
    • Thread