• 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: Writing large scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing large scripts


  • Subject: Re: Writing large scripts
  • From: Timothy Bates <email@hidden>
  • Date: Sun, 13 May 2001 23:24:28 +1000

On 13/05/2001 9:50 PM, "Jan Erik Mostrvm" <email@hidden> wrote:
> Thanks for all your for suggestions (a special "Thank you" to Bill Cheeseman).
> My main problem isn't really with the script size (I haven't counted but I
> don't think I have many scripts with more than 500 lines). My problem has been
> how to organize them.

My solution (recently settled upon) is to create objects rather just bunches
of handlers. Then load these into every new script that I write.

For instance, I have a "screen" object which knows how to do a whole bunch
of related things like take data on the size of screen a viewer is looking
and tell me the degrees of visual angle a shape occupies. I have other
objects, for instance, my file object can read and write spreadsheet data,
sort and manipulate lists, etc.

To get the benefit, you need to easy access these in every script you write.
My solution was to write a new script handler in Script Debugger. Now every
new script has the code to load these libraries included effortlessly.

you nee to pick a place to store your objects (along side your scripting
additions is just fine)

Then load them with a call like

set fileHelper to (load script (path to scripting additions) & "file.lib"


From then on these libraries are available in every script that includes
this line!


Now you can just say

tell filehelper to writeToFile({{1,2,3},{"a","b","c"}})

get distance of screen

new randList to (filehelper's randomize(myList) )


The neato thing is you can really start to build some great and refined
handlers, because you know they are going to pay you back in the future. For
instance my write to spreadsheet handler has cool error handling, can cope
with various dimensionalities of list (or just straight text) with aplomb.
This accumulated over a few months of incremental improvements

Motto: script libraries - put evolution to work on YOUR side.

good luck,

tim


Dr Timothy Bates <mailto:email@hidden>
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University
Ph 61 (2) 9850 8623
Fx 61 (2) 9850 6059


References: 
 >Re: Writing large scripts (From: Jan Erik Moström <email@hidden>)

  • Prev by Date: Re: Writing large scripts
  • Next by Date: Scripting The Command key
  • Previous by thread: Re: Writing large scripts
  • Next by thread: Re: Writing large scripts
  • Index(es):
    • Date
    • Thread