Applescript help
Michael Johnston
lastobelus at mac.com
Sat Apr 16 07:24:55 PDT 2005
There are several major sources of frustration in using applescript
beyond trivial one-liners:
1. No effort whatsoever has been made by Apple to keep Applescript
up-to-date as a scripting language. There's no builtin regex. There are
no dictionaries (associative arrays) and records have symbolic,
compile-time keys. It's not very dynamic in general, although you can
use run script sort of like an eval to add some limited degree of
runtime dynamicism. So using applescript to do string/data munging is
an exercise in tedium & frustration. You can solve some of these
problems with third-party solutions, but it's a hassle.
2. Applescript is giving you access to data structures in third party
apps. The guidelines for how this is done are somewhat arcane and not
particularly well-documented (this is changing with cocoa). So,
different developers do it in different ways. This means that any task
that seems like, say, half an hour of programming must be well-padded
to accomodate the possibility that you'll end up spending an hour or
more of trial and error to find the one arcane way of referring to the
data you need in the one particular context you need it in.
3. The one single great feature of Applescript as a language, filter
expressions, works only with application data structures, not with data
structures you make yourself. This plus the awkward, limited language
features for working with the list type add a lot of overhead to basic
programming tasks that is not present in other languages, despite the
fact that you can sometimes write these incredibly expressive one
liners for getting a dataset from an application. But I'd gladly gladly
trade filters for even just dictionaries with string keys.
4. The syntax is so bizarrely different than all other languages that
your programming instincts & experience won't serve you nearly as well.
Even worse, doing a lot of Applescripting tends to contaminate your
regular programming skills/instincts.
Have a look at appscript, which lets you program in python. To make it
"attachable", you'll need OSAPython.
appscript: http://freespace.virgin.net/hamish.sanderson/appscript.html
OSAPython: http://homepage.mac.com/philip_aker/osa/osa.html
I'm working on porting appscript to PHP, but I have limited time for
this project so it's likely to take a few months before it's finished.
I love what Applescript/OSA allows me to do, but after 40-50k lines of
it, I personally have come to loathe it as a language with an intensity
that is legendary in my firm.
Michael Johnston
On 15-Apr-05, at 11:11 AM, AntToeKnee.9604432 at bloglines.com wrote:
> Hello,
>
> I'm pretty new to applescript but have a lot of programming experience.
> I'm trying to delete the selected row in an outline, using;
>
> tell front
> document of application "OmniOutliner Professional"
> delete selected row
>
> end tell
>
> But nothing happens. If I vary the script to
>
> tell front
> document of application "OmniOutliner Professional"
> delete every row
> end
> tell
>
> they all get deleted. What am I doing wrong? I'm using the latest
> OO3 Pro under Jaguar (I've ordered Tiger so can wait if it is a OS
> version
> thing)
>
> Also, generally how to I find what applescript bindings are available
> for a particular application? In the case of Omnioutliner I can find
> no mention
> of the objects specific to that application. Surely there must be
> per-app
> documentation?
>
> -thanks
> _______________________________________________
> OmniOutliner-Users mailing list
> OmniOutliner-Users at omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/omnioutliner-users
>
More information about the OmniOutliner-Users
mailing list