• 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: mac script size revisited
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: mac script size revisited
      • From: Michael Glasser <email@hidden>
References: 
 >Re: mac script size revisited (From: Michael Glasser <email@hidden>)

  • Prev by Date: Re: mac script size revisited
  • Next by Date: Re: can't get it to work
  • Previous by thread: Re: mac script size revisited
  • Next by thread: Re: mac script size revisited
  • Index(es):
    • Date
    • Thread