On 12/7/02 08:04, Gary Lists wrote:

> On or about 12/7/02 7:54 AM, Diane L. Schirf wrote:
> 
>>> In the interest of writing scripts more efficiently and more compatibly, I
>>> was wondering if any of you Master Scripters have (and would be willing to
>>> share) a library file of some common Entourage script tasks?
>> 
>> <http://www.applescriptcentral.com/>
> 
> 
> Yes, I know there are script collections. I was referring to an actual
> library file, for calling from within scripts. A library of handlers and
> other methods. :)

The thing is, each programmer (or scripter, if you prefer) has an individual
style and preferences. Such a compilation of snippets from different people
(Paul, Allen, Barry, Mickey, even myself from time to time), is much more
useful as a learning tool. IMO, the major drawback to using a 'library' is
that you start to rely on just using that code, and never really develop an
understanding of why or how it works. And that's where the real power of
AppleScript lies, in allowing you to create solutions that are unique to
your situation, and not having to rely on someone else to do it for you.

In that sense, Diane's suggestion to check AppleScriptCentral is an
excellent one.

Related to the 'individual style' thing is the fact that there often is not
just one way to do something in AppleScript. One way may be more efficient
than another in a given set of circumstances, but less so under other
circumstances. Code libraries get awfully complex if they attempt to cover
all the bases, so you may end up using a routine that's not really
appropriate (although neither is actually 'right' or 'wrong').

Consider this example: I want to combine 2 words with a <space> between
them:

    set a to word1 & " " & word2

Or I could do this:

    set tid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to " "
    set a to text items of {word1, word2} as string
    set AppleScript's text item delimiters to tid

For just a couple of words the first is by far the best way to go. But if I
have a lot of words, the 2nd method would probably be faster. If my code
library shows just the first method, and I have six words to combine, I'll
be doing...

    set a to word1 & " " & word2 & " " & -- etc up thru word6

...because I may not know any better. Similarly, if all I know about is the
2nd method, I'll be using much more code than I need to simply combine word1
with word2.

Which all comes back to *learning* AppleScript, rather than just using it.

Now, I realize, Gary, that you have learned a bit about AppleScript, so such
a library would probably be more of a leg up for you, rather than a
substitute for learning to script.

But, what makes a good script a great script (and I don't pretend that most
of mine come close to the latter category) is error trapping and preventing
errors. A routine may include error trapping code, but it's not always
appropriate to do that within the routine; it may only be what you do with a
result that can cause an error. In that case, just having the routine does
you no good if something goes wrong (another case of learning the ins and
outs, you see).

Ah, well...I've rambled on longer than I intended. I'll add, though, that if
such a library were available, I'd probably get it myself. I'm very bad
about keeping track of my own stuff: my 'code library' is often a saved
message with the relevant code, or a script I cannibalize.


George

-- 
George Clark - [EMAIL PROTECTED]



-- 
To unsubscribe:                     
<mailto:[EMAIL PROTECTED]>
archives:       
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:       
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to