[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Getting started with Applescript & Perl



>>I now have MacPerl 5.0.7 installed and Applescript. What I
>>would like to do from MacPerl is to tell GraphicsConverter
>>to open a specific file, or Netscape to open a file or
>>URL. Is this hard to do in Applescript?
>
>I don't think GraphicsConverter is scriptable.

There's a tool available, that can make almost any application scriptable.
It's called Prefab Player. I haven't tried it out yet, but Danny Goodman
(from the book) is quite lyrical about it. It works along the lines of
QuicKeys: scripting the mouse and the keyboard.

>>Maybe I should buy a book on Applescript. What books do you
>>recommend? I've seen a book titled "The Tao of Applescript"?
>
>There are two good third-party books on AppleScript, and you should read
>them in this order:
>
>The Tao of AppleScript, 2nd Edition, by Derrick Schneider (Hayden Books)
>Danny Goodman's AppleScript Handbook, 2nd Edition, by Danny Goodman (Random
>House)
>
>The Tao is pitched at beginning scripters, and is highly didactic.  Danny
>Goodman's book is drier, but ultimately more informative.

>There are a couple of other books on AppleScript, including "Applied Mac
>Scripting" and "AppleScript for Dummies".  I haven't really looked at
>either one, though Applied Mac Scripting contains a long section on
>Frontier, which a lot of programmers prefer to AppleScript.

I know the books by Danny Goodman (excellent) and the fat one, "Applied Mac
Scripting" by Tom Trinko. The latter is just a waste of money.

It contains hardly any valuable information, contains a lot of unfunny
humour, is organised in a "chronological" order, not by subject, and very
difficult to look anything up. It's also very superficial (no tricks of the
trade).

On the other hand: Danny Goodman's book is well organised, and describes in
detail a lot of the quirks of Applescript.


>You might want to consider learning Frontier as an alternative to
>AppleScript.  Because AppleScript is verbose and not particularly fast, it
>is often perceived as lacking power.
>Frontier, on the other hand, is extremely powerful and very
>fast, though it is unnecessarily obscure.  Its scripting language is
>similar to that of the C programming language, with some bizarre
>modifications.  It is not well-suited for non-programmers.

I've tried both Frontier and Applescript. I don't really like Frontier: it's
weird.

Applescript is in fact quite powerful in it's support of lists and records.
A very weak point, is that you can't take a substring of a piece of text,
without changing it to a list of characters first, and converting the result
back to text. Very slow, and sometimes you get out of memory because of
this. Note: this is a bug. The phrase "text of ..." should avoid it, but it
doesn't.

About the speed difference: this depends on what you want to do. In cases,
Frontier is (about 5 times, rough guess) faster than Applescript.

A lot of the lack of speed of both has to do with Apple Events. These are as
slow for both Applescript and Frontier. So, in general, expect resulting
speeds to be comparable.

I've tried to build some programs in both, and for one program, Applescript
was *twice as fast* than Frontier (57 seconds Fr vs. 31 AS)! It looks like
Frontier's functions putAppleListItem() and string.nthfield() are to blame
for this.


So, if you don't like Frontier (like me), don't feel pushed to use it.


Bart Lateur,
Gent (Belgium)