• 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: AppleScript and shell scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript and shell scripting


  • Subject: Re: AppleScript and shell scripting
  • From: has <email@hidden>
  • Date: Sun, 29 Jul 2007 22:18:11 +0100

Mark J. Reed wrote:

On 7/29/07, Michelle Steiner <email@hidden> wrote:

How would you add an email address to a contact (AKA: person) in the Address Book using perl or tcsh?

Here is how to do it with Applescript:

tell application "Address Book"
        tell item 1 of (get the selection) to make new email with
properties
{label:"home", value:"email@hidden"}
        save addressbook
end tell

I couldn't tell you the Mac::Glue code offhand as I don't use Perl myself; however, here's the equivalent Ruby code:


AB = app('Address Book')
person = AB.selection.get[0]
person.make(:new => :email,
:with_properties => {:label => 'home', :value => 'email@hidden'})
AB.save_addressbook



And until you told me that, I would have had absolutely no idea. I believe
that's the whole point: the alleged transparency of AppleScript is a
fallacy brought on by familiarity.

Technically, this is a general application scripting issue (the perennial problem of application developers not providing sufficent documentation), not an AppleScript-specific problem, and therefore a separate topic to this thread. It just so happens that AppleScripters are the best folk to ask for advice on how to do it as they have the most collective experience in doing application scripting, but that's orthogonal to deciding which language to do it in.



Now, I could do that in Perl - now that you've shown me the events,
properties, etc involved - using Mac::Glue, or Mac::AppleScript::Glue, or
Apple::Events::Simple, or something, but that would be silly. Scripting Mac
applications is what AppleScript is for, and I don't see any reason to do
that in any other language.

Here's a good technical reason: AppleScript is good at application scripting and lousy at everything else. Perl [1], Python, Ruby and ObjC are good at application scripting and other things as well. If you need to do application scripting AND these other things as well, it's generally easier to do everything in one of these languages rather than in a combination of AppleScript and another language (which means dealing with bridging issues) or AppleScript alone (which means dealing with AppleScript's lousy aspects).


has

[1] Technically, Perl+Mac::Glue isn't as good as AppleScript, but not being a Perl expert I couldn't tell you how much that's due to Mac::Glue not being as good as it could be and how much it's due to the general difficulty of gluing Perl and Apple event technologies together.
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html


_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Re: AppleScript and shell scripting
  • Next by Date: Re: AppleScript and shell scripting
  • Previous by thread: Re: AppleScript and shell scripting
  • Next by thread: Re: AppleScript and shell scripting
  • Index(es):
    • Date
    • Thread