Re: mac script size revisited
Re: mac script size revisited
- Subject: Re: mac script size revisited
- From: Richard Morton <email@hidden>
- Date: Thu, 10 Apr 2003 16:08:38 +1000
On Thursday, April 10, 2003, at 01:38 PM, Michael Glasser wrote:
One problem... you say for sanities sake that I should not rely on
globals... well, apparently I am not sane. :)
You're not alone either. ;)
I have ONE global variable that I can not find a way to not need to
pass... my functions not only rely on it to come up with a result,
they also sometimes effect this variable.
Any ideas on how I can deal with globals? Just one variable... if
that helps...
Three methods come to mind immediately.
(1) Pass it to & return it from to every handler that needs it:
tell myLib to set {myAnswer, globalValue} to doStuff(requiredData,
globalValue)
In the lib:
on doStuff(data, globalVar)
-- do things with data
return {handlerResult, globalVar}
end
(2) Limit the use of the global to one library only and declare it as
a global/property in that. It can still be returned to the main script
if/when required.
(3) Redesign your script so the global is no longer required. This is
not always easy, but eliminating dependencies on external values really
helps with debugging, maintaining & re-using code. It may also push
you toward an improved overall structure - time consuming in the short
term, but you'll be better off in the long run.
Cheers,
In D Pendent
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.