Re: passing handler problems and a resolution
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