O'Reilly logo

Apple Pro Training Series: AppleScript 1-2-3 by Bill Cheeseman, Sal Soghoian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 16. Subroutines

What Is a Subroutine?

How Does a Subroutine Work?

Why Use Subroutines?

An Example Using iTunes

Subroutine Miscellany

What’s Next?

Anytime a script you’re working on starts to get long and complicated, you should think about using subroutines. Subroutines are also sometimes referred to as subroutine handlers or, simply, handlers.

In this chapter, we’ll explain subroutines and demonstrate them using a single, long script. The script is fun to use if you have a lot of songs in your iTunes library. It asks you for a “theme”—a word or phrase that might be found in the titles of several of your songs, such as love or crazy—and creates a new playlist in iTunes gathering them together for easy listening. Alternatively, it creates ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required