• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

7. Advanced Techniques > 88. Streamline Your AppleScripts

Streamline Your AppleScripts

If you use a Macintosh, you can simplify your scripts by adding your own commands to Indigo and XTension using a little-known AppleScript feature.

If you’ve written a snippet of AppleScript that you need to use in several places—such as a routine that converts elapsed seconds to days, hours, and minutes [Hack #97] —you’ll appreciate that Indigo and XTension both support attachability. Attachability enables you to define new commands (known as handlers in AppleScript parlance), and it can greatly simplify your system.

Instead of having to paste a copy of a favorite routine into every script that needs it, you have just one copy that any script can call.

Here’s a simple example. Suppose you’re using text-to-speech to make announcements. You want to use the voice called Fred to announce regular events and the Zarvox voice to announce anything that’s urgent. You can simply hardcode the appropriate voice every time you use it:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint