Learn To Speak AppleScript, Part 2: Baby Steps

“I Four Years Old!”

You’ll notice how explicit I was in calling out each part of what I wanted to do.

This way of thinking in terms of “baby steps” towards your overall goal is probably the most important thing you can take from this lesson.

Here’s why — AppleScript is great, but teaching it to do what you want it to do can be like trying to teach a child. You really need to try and see things through the eyes of a kid (or, in this case, a computer that knows only what you tell it) in order to know how to communicate.

Rule #2:
AppleScript is like an energetic child. It’s eager to please — but in need of clear, constant direction.

It reminds me a bit of that old Bill Cosby comedy routine about a kid named Jeffery:

If you have any hope of getting off the plane with your sanity intact, you’re going to have to learn how to translate your adult language into something a kid can understand. That is to say, it’s something you’re absolutely going to be able to do — it’s just going to take a brief transition while you take a deep breath and mentally switch gears from your language and into theirs.

Sometimes, Kids Just Don’t Understand

I’ll make one more point using the “Talking To Kids Metaphor” as we end Part Two…

Every kid is different.
Some are barely able to tie their shoes.
Some come up to you and, unprompted, freak you out by asking if you’re an existentialist.

In the world of AppleScript, each of the applications on your Mac — programs like Apple Mail, Firefox, Evernote, iCal, etc. — are like kids at different grade levels. And, although you can sometimes guess, you’ll never really know which type of kid it is until you start talking to them and figure out their vocabulary level.

And this is the point where, thankfully, reality departs from the metaphor: In the computer world, you can actually see which words an application knows ahead of time — sparing you painful, Jeffery-like conversations. When it comes to speaking AppleScript, each program keeps a list of the vocabulary it knows in an AppleScript Dictionary. (Easy to remember, right?)

Ready To Talk?

In Part Three, we’ll open up that dictionary and start having an AppleScript conversation with a fairly “well-spoken” kid on the Application playground — Apple Mail!

10 Responses to “Learn To Speak AppleScript, Part 2: Baby Steps”

  1. up0 March 8, 2010 at 1:59 pm #

    great analogy. Applescript is like learning to talk in some kids’ language…

    • Justin March 8, 2010 at 4:08 pm #

      Glad you enjoyed it… Part 3 coming soon!

  2. Rubarb April 7, 2010 at 1:56 am #

    where is part 3?

    • Justin April 7, 2010 at 2:10 am #

      I was hoping that there was someone out there who cared enough to ask — “Rubarb” is officially Veritrope’s “Reader of the Day”! 😀 ((Don’t Worry: I won’t put your picture up on a special plaque or anything!))

      Part 3 was slightly derailed by both a bad internet connection (not a surprise if you’ve seen the front page lately) and also some needed bug fixes to one or two of the AppleScripts I publish here.

      I’d say look for it by the end of this week… Fair enough?

      Are you enjoying the approach? Finding it helpful?

      • Rubarb April 7, 2010 at 2:16 am #

        Well, I like the idea of a plaque 😉

        Parts 1 and 2 are great to read! Very involving and engaging… Love to find more info about Apple Script! I’m new to this site so am looking forward to exploring more.

        Thanks Justin!

        R

        • Justin April 7, 2010 at 2:51 am #

          Just checked out your link — must be serendipity as I am a many-time-customer of macProVideo (I **KNEW** I liked you guys for a reason — you have excellent taste in websites! 😉 ). When my clients are looking for an in-depth training series, I often recommend your stuff as well.

          Anyhow, it had been a while since I checked in — saw your Advanced Snow Leopard tutorial on offer… Looks good! Will certainly scoop that up along with a few others once you guys release your iPad app! (wink-wink, nudge-nudge)

          If I can get Part 3 out the door this week, I’ll also try to post some Services for Snow Leopard that I use privately, but haven’t published yet. Here is a link to the Services that I **have** already published…and also a directory of others I have found on my internet travels. (Based on your tutorial, I thought you might “be feeling it”.)

          And now to find a plaque….

          • Rubarb April 7, 2010 at 4:25 am #

            Hi Justin,

            Thanks! We do indeed have impeccable taste in good websites… as you do have excellent taste in good training videos 😉

            Indeed, I am Rounik… and the Advanced Snow leopard tutorial is my first full foray into the wonderful world of online video tutorials.

            You can already use NEDi (for iPhone/Touch) on the iPad… but of course users can then watch the library of videos in iPhone native res or upscaled x2… I haven’t had a chance to test it out as the iPad hasn’t arrived this side of the pond yet in the UK, or indeed in Canada… 🙁

            But, until NEDi for iPad is released that’s the best solution.

            I’m looking forward to Part 3. I genuinely love your writing style. Part 3 will be great… (no pressure then 😉

            Yes, indeed, I pick up from the Mac OSX 101 tutorial and cover Automator and Services and the Terminal… So I’m downloading your freebees now. Many thanks!

            The kind words and link to my tutorial are better than any plaque could be!

            btw, if you’re interested in joining the macProVideo.com affiliate programme, here is the link:
            http://www.macprovideo.com/affiliates/

            If you’re ever around the forums on macprovideo pop in and say hi!

            Thanks again!
            Rounik