AppleScript - Mark Conway Munro - E-Book

AppleScript E-Book

Mark Conway Munro

0,0
30,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Developers will advance their AppleScript skills easily with this guide Part of the Developer Reference series, this book is packed with professional secrets for designing and building automated solutions with AppleScript, the powerful, system-level scripting language built into every Mac. Programmers will discover new ways to increase their professional efficiency and become more valuable in their jobs. With up to date coverage of Mac OS X 10.6 Snow Leopard and loaded with real-world tips and techniques, this guide includes best practices and conventions along with informative lessons. You'll advance your scripting skills to the next level under the direction of a long-time veteran of the AppleScript community. * Provides step-by-step lessons for designing and building automated solutions with AppleScript * Written by a well-respected veteran of the AppleScript community * Part of the Developer Reference series that focuses on enhancing the skills of professional Apple developers * Filled with professional secrets, tips and techniques to help programmers increase their professional value * Includes best practices, naming conventions, and much more With the information you'll get from AppleScript,you'll become a better and more effective developer. Note: CD-ROM/DVD and other supplementary materials are not included as part of eBook file.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 789

Veröffentlichungsjahr: 2010

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



AppleScript®

Table of Contents

Part I: AppleScript: The Power of Automation

Chapter 1: Introduction to AppleScript Programming

A Brief History of AppleScript

Finding AppleScript Resources

Applications

Scripting additions

Components

Understanding the Unique Characteristics of AppleScript

English-like syntax

Universally open-ended

Deep level of access

Consistency maintained between updates

Exploring the Uses and Users of AppleScript

Uses for AppleScript

Users of AppleScript

Respecting the Power of AppleScript

Summary

Chapter 2: Workflow Automation with AppleScript

Defining Workflow Automation

Busting some myths about automation

Exploring reasons to automate a workflow

Using AppleScript for Workflow Automation

Understanding the scalability of AppleScript

Quantifying the return on investment potential of AppleScript

Summary

Chapter 3: AppleScript Deployment Options

Exploring AppleScript Formats

Saving scripts as files

Saving scripts as applications

Exploring Script Deployment Locations

Mac OS X installation locations

Mac OS X usage locations

Third-party application locations

Choosing a Format and Location

Summary

Chapter 4: Making the Case for Standardization

Understanding the Benefits of Standards

Consistency

Repurposing

Enhanced efficiency

Improved quality

Collaboration

Automation

Professionalism

Exploring the Flexibility of Standards

Applying standards within a context

Setting your own standards

Defining AppleScript Naming Standards

The goals of naming standards

Naming variables

Naming subroutines

Defining AppleScript Usage Standards

The goals of usage standards

AppleScript usage standards

Summary

Part II: Learning the AppleScript Language

Chapter 5: Exploring AppleScript Basics

Understanding AppleScript Terminology

Commands

Literals

Keywords

Operators

Object classes

Variables

Statements

Subroutines

Scripts

Looking at AppleScript Comments

Commenting methods

Uses for comments

Frequency of comments

Commenting usage conventions

Planning Scripts

Pre-coding steps

Coding steps

Summary

Chapter 6: Getting Started with the AppleScript Editor

Exploring the AppleScript Editor User Interface

The script document window

Contextual menus

Menus

Preferences

Library window

Event Log History window

Building the “Hello World” Script

Creating the script

Expanding the script

Summary

Chapter 7: Working with Text Objects

Introduction to Text Objects

Text object properties

Special consideration for quotes

Analyzing Text

Counting text

Searching text

Comparing text

Considering and ignoring text

Manipulating Text

Merging text

Splitting text

Extracting text

Converting text to other data types

Using text item delimiters

Summary

Chapter 8: Working with Numbers and Unit Types

Introduction to Number Objects

Looking at types of numbers

Putting a number into a variable

Comparing numbers

Manipulating Numbers

Performing calculations

Converting numbers

Working with Measurement Unit Types

Using measurement types

Converting within the type group

Converting to other data types

Summary

Chapter 9: Working with Dates and Times

Introduction to Date Objects

Date object properties

Manipulating Date and Time

Comparing dates

Performing calculations with dates and times

Summary

Chapter 10: Other AppleScript Data Classes

Working with Booleans

Working with RGB Colors

Working with Aliases

Working with Files

Working with References

Summary

Chapter 11: Working with Lists

Introduction to Lists

Looking at list properties

Looking at specialty lists

Analyzing Lists

Counting list items

Comparing lists

Considering and ignoring text properties

Searching in lists

Manipulating Lists

Converting lists to other data types

Extracting list items

Adding items to a list

Replacing items in a list

Removing items from a list

Summary

Chapter 12: Working with Records

Introduction to Records

Comparing an AppleScript record to a database record

Looking at record properties

Creating a Record

Analyzing Records

Counting records

Comparing records

Considering and ignoring text properties

Manipulating Records

Converting records to other data types

Extracting data from a record

Adding something to a record

Replacing a value in a record

Removing a value from a record

Summary

Chapter 13: Logical Branching

Looking at the Anatomy of an if-then Statement

Building a conditional “Hello World” dialog

Expanding the equation

Creating a Multiple Condition Statement

Adding Additional Conditions

Using Nested Statements

Understanding Common Mistakes

Missing parenthesis

Missing conditions

Conditionally undefined variables

Summary

Chapter 14: Looping

Looking at the Anatomy of a Repeat Statement

Defining the Types of Repeat Loops

Repeat (until exit)

Repeat x times

Repeat while

Repeat until

Repeat with a from x to y {by z}

Repeat with a in list

Nesting Repeat Loops

Using Repeat Loops

Creating with repeat loops

Modifying with repeat loops

Extracting with repeat loops

Processing files with repeat loops

Summary

Chapter 15: Dealing with Script Errors

Introduction to Script Errors

Defining programming errors

Defining situational errors

Exploring Error Management

Looking at the anatomy of a try command

Handling multiple errors

Generating your own errors

Understanding cascading errors

Recording Errors Into a Log File

Writing information to the event log

Writing errors to text files

Looking at the AppleScript and Mac OS X Errors

Summary

Chapter 16: Getting Started with Scripting Additions

Finding Scripting Additions

System Library folder

Library folder

User's Home Library folder

Embedding Scripting Additions

Working with Standard Additions

User Interaction

File Commands

String Commands

Clipboard Commands

File Read/Write

Scripting Commands

Miscellaneous Commands

Folder Actions

Internet

Summary

Part III: Using Scripts to Control Applications

Chapter 17: Controlling Applications with Scripts

Introduction to Application Automation

Looking at the “tell application” statement

Managing timeouts

Ignoring an application response

Respecting hierarchy when nesting disparate control commands

Defining different types of AppleScript support

Exploring an Application's Dictionary

Opening a dictionary

Exploring the dictionary interface

Exploring an application's dictionary content

Using AppleScript to Control Applications

Activating, launching, and quitting applications

Manipulating the Finder with scripts

Controlling Inter-Application Communication

Controlling Remote Applications

Configuring Remote Apple Events

Understanding eppc computer specifiers

Sending commands to a remote application

Compiling a script using terms from a local application

Summary

Chapter 18: Working with Image Events

Introduction to Image Events

Getting started with basic functionality

Reading properties of an image file

Manipulating an image

Creating an Image Batch Processor

Summary

Chapter 19: Working with Database Events

Introduction to Database Events

Getting started with basic functionality

Working with database records

Working with fields

Searching a Database

Searching for text values

Searching for numeric values

Searching for date values

Searching for multiple values

Importing Records from Tab-Separated Files

Summary

Chapter 20: Working with System Events

Introduction to System Events

Getting started with basic functionality

Exploring the suites of commands

Controlling Non-Scriptable Applications

Enabling User Interface Scripting

Activating and targeting applications

Referencing objects in an application's interface

Accessing information from an interface

Performing User Interface Scripting actions

Creating a Zipped Archive File with System Events

Summary

Part IV: Using Subroutines and Open-Ended Programming

Chapter 21: Using Subroutines for Non-Linear Programming

Working with Subroutines

Calling a subroutine from a tell application statement

Exchanging data with subroutines

Identifying command handler subroutines

Commenting subroutines

Exploring the Benefits of Subroutines

Easing developer tasks

Reusing code

Allowing advanced script design

Resolving variable names conflicts

Designing a Non-Linear Script

Understanding when to delimit a script into subroutines

Looking at the methods of delimiting a script

Summary

Chapter 22: Introduction to Open-Ended Programming

Understanding the Benefits of Open-Ended Code

Makes recycling code easy

Improves script quality

Encourages consistency

Justifies smaller scripts

Creating Open-Ended Code

Use repeat loops to remove duplicate code

Use the Finder selection

Provide for an empty selection

Allow folders to be processed

Dynamically count the name's length

Use text item delimiters

Use variables or script properties

Query user input

Use subroutines

Creating Open-Ended Subroutines

Divide code with logical groupings

Make smaller subroutines

Name subroutines, parameters, and variables generically

Avoid branch-style openness

Use subroutine parameters for variable input

Use records for future parameter expansion

Keep subroutines as portable as possible

Creating an Open-Ended Image Batch Processor

Allow a user to select folders

Enable two additional selection methods

Choose manipulations

Select a custom scale percentage

Allow the user to choose an output format

Allow the selection of multiple output formats

Make a drop application

Use subroutines

Bring it all together

Summary

Chapter 23: Designing a Hierarchical Subroutine Structure

Defining the Goals of Subroutine Hierarchy

Produce a flexible and expandable script

Maximize reusable code

Create portable code

Achieve a separation of data from function

Facilitate a multi-module solution ideology

Identifying the Primary Levels of Hierarchy

Maintaining flexibility within levels

Following proper inter-level communication

Identifying Hierarchy-Related Issues

Project-specific elements

Open-ended elements

Creating a Image Batch Processor with a Hierarchical Subroutine Structure

Outlining the new subroutine structure

Rebuilding the script

Summary

Part V: Organizing Code into Modules and Libraries for Multi-Module Solutions

Chapter 24: Introduction to Multi-Module Solutions

Understanding the Benefits of Multi-Module Solutions

Eases developer tasks

Allows advanced script design

Designing a Multi-Module Solution

Defining types of script files

Exploring file structure options for complex solutions

Understanding inter-script communication

Overcoming the Complexities of Multi-Module Solutions

Employing good development habits

Using logs for tracking

Building a Multi-Module Image Batch Processor

Designing the new solution

Building the Logging Module file

Building the Finder Library file

Building the Image Events Library file

Building the main Image Batch Processor file

Summary

Chapter 25: Designing Open-Ended, Multi-Module Solutions

Planning for Change

Anticipating business changes

Anticipating development changes

Upgrading the Image Batch Processor to an Open-Ended, Multi-Module Solution

Creating the new module template

Setting up the Scale module

Setting up the Flip module

Modifying the image batch processor module

Creating a new Rotate module

Further expansion and inspiration

Summary

Appendix A: AppleScript Web Resources

Developer Connection main page

AppleScript documentation and resource main page

Introduction to AppleScript overview page

AppleScript language guide

AppleScript release notes

Apple's AppleScript Users

Mac Scripting Systems (MACSCRPT)

Script Debugger

Smile

MacScripter

UI Browser

MacTech's Visual Basic to AppleScript guide

Write Track Media

AppleScript®

Mark Conway Munro

AppleScript®

Published byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com

Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana

Published by Wiley Publishing, Inc., Indianapolis, Indiana

Published simultaneously in Canada

ISBN: 978-0-470-56229-1

Manufactured in the United States of America

10 9 8 7 6 5 4 3 2 1

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, 201-748-6011, fax 201-748-6008, or online at http://www.wiley.com/go/permissions.

Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read.

For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (877) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.

Library of Congress Control Number: 2010925705

Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. AppleScript is a registered trademark of Apple, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book. AppleScript® Developer Reference is an independent publication and has not been authorized, sponsored, or otherwise approved by Apple, Inc.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.

Credits

Acquisitions Editor

Aaron Black

Executive Editor

Jody Lefevere

Project Editor

Katharine Dvorak

Technical Editor

Rob Vanderwerf

Copy Editor

Lauren Kennedy

Editorial Director

Robyn Siesky

Business Manager

Amy Knies

Senior Marketing Manager

Sandy Smith

Vice President and Executive Group Publisher

Richard Swadley

Vice President and Executive Publisher

Barry Pruett

Project Coordinator

Lynsey Stanford

Graphics and Production Specialists

Andrea HornbergerErin Zeltner

Quality Control Technician

John Greenough

Proofreading

C. M. Jones

Indexing

WordCo Indexing Services

Media Development Project Manager

Laura Moss

Media Development Assistant Project Manager

Jenny Swisher

Media Development Associate Producer

Doug Kuhn

About the Author

Mark Conway Munro is an entrepreneur who turned a software-writing hobby into a business. Mark was born in Indiana and raised in Ohio. In 1986, Mark moved to New York City. As the manager of Louis Tannen's Magic Store in New York City, he taught himself the Macintosh Computer and FileMaker Pro while building a database of inventory, which eventually led to the development of a networked order processing solution. From there he went on to work for the Jack Morton Company, where he was the Network and Telecommunications Manager. He began developing custom solutions with HyperCard and FileMaker Pro in his spare time. After the release of AppleScript in 1992, he refocused his experience with computer networking, training, technical support, database development, and custom application development. He quickly transitioned from HyperTalk to AppleScript and began building custom workflow automation solutions.

Mark founded Write Track Media in 1994, where he continues to develop innovative solutions that eliminate repetition and optimize computerized workflows. Write Track Media has since become known for its reputation for excellence, and has developed complex automated solutions for companies in a variety of industries all across the country including Adobe Systems, The Associated Press, BMG, Dreyfus, Entertainment Weekly, Epson, KraftMaid, McCann-Erickson, The Miami Herald, MYOB, Nabisco, NASA, Nikon, Random House, Reader's Digest, Sony Music Entertainment, and many other companies.

Currently Mark resides in Pennsylvania, where Write Track Media is located. In his spare time, he enjoys hiking and nature photography.

Dedication

To my father, Philip Conway Munro, for teaching me the difference between hardware and software at an early age.

Foreword

Twelve years ago Mark Munro asked me to write something for the Web site he was building for his company, Write Track Media. I had already been working with him for about three years: me as an editor and in-house FileMaker developer at the country's second-largest record company, and Mark as outside FileMaker and AppleScript developer. He had helped build the departmental Mac-based database of discs, tapes, and videos with up-to-date listings of all their artists, prices, genres, formats, and so on. But the major part of the project, and where Mark was proving so invaluable, was in the system's output.

We needed to produce a monthly pocket-sized catalog of the active product — about 13,000 data records. Mark automated production so that I could generate a 180-page complexly styled catalog — using FileMaker Pro, AppleScript, and Quark — at the push of a button. We needed to constantly produce multipage order forms with elaborate line listings and scannable barcodes. Mark automated these so that one button would trigger the form to build from scratch: Quark firing up, new blank documents opening, text boxes being created and placed, text flying into the boxes, picture boxes being created, AppleScript running off and building barcode images for each product, bringing them back, dropping them into the picture boxes, sizing them to fit…. All this looked like magic to the IT guys that would drop by occasionally, none of them Mac users, with no idea that an application like AppleScript existed that could make the programs all “talk” to each other. It was magic to us, too: the documents were data driven, accuracy was better than it ever had been, and the automation was saving countless hours of typing, page layout, and proofreading every week.

New record formats were coming into being; sales needs and the documents supporting them were changing often. I was pressed for time and got to work with Mark a lot. The thrill was that I could call him and tell him what I needed and he'd never get nervous or show hesitation, and he'd never say it couldn't be done. There was always a way, and for him, always a good way. He worked fast and methodically, kept me briefed, and generally delivered ahead of his target date. I would send lists of fields, find and sort rules, and layout requirements. He would send code. I wrote for his Web site, “There seems to be no limit to the complexity of the scripting and automation jobs they are able to take on, and they do it with an energy, focus, speed, and levelheaded aplomb that are to be admired.” “They,” of course was all Mark himself, and I feel the same twelve years later.

It's not surprising to me that Mark, early in his career, was a performing magician who got his start with databases when he decided to computerize the inventory at Tannen's, the New York City magic supply mecca where he was working. I don't mean this in the hokey, “Oh, this guy works magic” sense; I mean that like a skilled performer he has brought to his work in these intervening years a rigorous, practiced, polished, and intensely methodical approach. He has developed a remarkable overview of the effects he wants to achieve. He has codified a highly refined aesthetic and has devoted himself to the rigorous practice that it takes to express it.

I went to the Apple Store last night and happened to mention to a young clerk that my friend was writing a developer guide to AppleScript. I was floored when he said, “Oh AppleScript — nobody talks about that around here — I think there's one guy that knows something about it and was thinking of using it to automatically update his phone, but he only knew how to get it to turn on and off.” Luckily, that's just ignorance, even if it's coming from an Apple employee: AppleScript remains an unparalleled development tool for desktop automation. It's not easy, and that's why there are specialists like Mark Munro. Sometimes it's hard to envision what it's capable of because it takes effort to zoom out, like a movie camera craning overhead, to get a real sense of what's possible to automate. Then building the solution can be daunting and time-consuming. It takes an effort to stop what you're doing by rote, and to devote time to changing direction. The resulting time savings and ease of operation can be thrilling.

I've heard a professional developer say, “What is good code? Good code is code that works.” I don't think Mark would say that. There's code that works and there's good code that works. It's not a fussy, perfectionist approach, either, just a sense of the intrinsic RIGHTness of an approach. He abhors wasted time and repetition of effort and spends remarkable effort in streamlining his FileMaker development practices and templates. This is to save time and money for his clients and, I think, to keep himself moving forward. It's obvious to me why his company's motto is: “Write Track Media creates solutions that eliminate repetition and allow our clients to focus on their highest potential.”

As a fledgling FileMaker developer, I have to admit that working with Mark over the years has been an occasional wellspring of inferiority feelings: “Is this the standard? Can I ever be a developer who's worth his salt if I'm not as good as Mark?” Maybe I can relax a little. I've come to believe that in all likelihood Mark's unique: perhaps there's no one as methodical and philosophically rigorous at what he does. But now that he's taking the time to codify his theories and his method, maybe we can get a little closer.

Walker StevensonFileMaker Developer

Acknowledgments

Writing this book was a tremendous effort and would not have been possible without the support, contributions, and encouragement of many people.

First, I want to thank John Thorsen, Jr., for the development opportunities he provided me many years ago. He is a constant source of advice, knowledge, and humor that would be difficult to find anywhere within a single human being. Also, thanks goes to Rob Vanderwerf for reviewing the manuscript with a keen eye for technical consistency and accuracy. His feedback led to many key improvements that greatly enhanced the quality of the material. To my friend, Walker Stevenson, for his meticulous nature, a willingness to discuss technical details, and for writing a foreword that makes it sound like I know what I'm doing. And to Aaron Black, Katharine Dvorak, and everyone at Wiley for providing me with this opportunity and for all their hard work.

Finally, a special thanks to all of my wonderful clients, especially those who have worked with me as an extension of their staff for many years. They have presented me with one challenge after another, constantly forcing me to push beyond my comfort zone. Many of the advanced concepts in this book would not exist without them.

Introduction

In the early 1990s, I was working as a Computer Network and Telecommunications Manager at the New York City headquarters of a company now known as Jack Morton Worldwide. In addition to my other responsibilities, I was tasked with creating FileMaker Pro databases to help manage the office's information. At that time, FileMaker was still somewhat crude, and had been since I began using it in the late 1980s.

During this time, I learned how to program HyperCard and was having a lot of fun building custom applications. Then I received a copy of the AppleScript Developer's Toolkit and Scripting Kit, an add-on piece of software for the Macintosh Operating System. I began converting the HyperTalk scripts in my applications to AppleScript. Almost immediately HyperCard was relegated to my archives in favor of AppleScript.

This was still a year or two before the Internet exploded in popularity. Finding documentation and sample scripts was difficult, and very few applications supported scripting. These difficulties led to many frustrating and yet ultimately rewarding, struggles to figure out how to successfully automate one task after another. However, as support for scripting spread out into the Mac OS and in third-party software, it became clear that workflow automation on a Mac was going to be a huge phenomenon.

This was a driving factor for founding Write Track Media in 1994 to specialize in the development of workflow automation solutions. Since that time, I have worked with many wonderful clients in a variety of different industries. Many times since then, I have entertained the notion of writing a book on AppleScript. Some of the techniques and ideas that I used daily, many created out of the necessity of the moment, seemed good enough to share. Believing that good ideas only become great when they are shared with others was a driving factor that led me to avail myself of the opportunity to write this book.

I tried to structure this book to appeal to programmers of any skill level, including those who have never programmed before. I start with the basics and gradually work toward more advanced material to make this book beneficial to all. It is laced with advice, ideas, and techniques gleaned from years of trial and error. Hopefully, you will find these useful and encouraging in your future automation endeavors.

AppleScript is a wonderful language to know and is powerful enough to automate virtually any task. It was a rewarding experience to focus on the language in a systematic fashion while writing this book. I hope you enjoy reading it as much as I have writing it.

Please let me know about issues you find in the book or offer suggestions for subjects you'd like to see covered in a future edition. Visit www.writetrackmedia.com/contact/ to send me an e-mail.

Getting the Most Out of This Book

The chapters in this book are organized into five parts. They are organized with the assumption that a reader will read the book from cover to cover. The material starts with the basics and gradually moves to more advanced material.

Part I, “AppleScript: The Power of Automation” includes an introduction and history of AppleScript as well as discussions of workflow automation with AppleScript and script deployment options. It also includes a presentation of a comprehensive set of naming and usage standards.

Part II, “Learning the AppleScript Language” begins with a chapter on AppleScript basics followed by chapters detailing each class of data that can be manipulated with scripts. From there, chapters discuss logical branching with if-then statements, repeat loops, error containment and management, and an in-depth look at how the standard scripting addition extends AppleScript's functionality.

Part III, “Using Scripts to Control Applications” reveals AppleScript's capability to tap into the functionality of standard, off-the-shelf software to create powerful multi-application workflows. Also, the three “faceless” applications — Image Events, Database Events, and System Events — included with the Macintosh operating system that provide additional functionality for AppleScript are covered in detail.

Part IV, “Using Subroutines and Open-Ended Programming” contains chapters that discuss the creation of subroutines, writing open-ended code, and an advanced discussion of using a hierarchical method for dividing code into subroutines.

Part V, “Organizing Code into Modules and Libraries for Multi-Module Solutions” continues to push into more advanced topics, discussing the development of complex AppleScript solutions that are spread across more than one script file.

Parts III–V contain several versions of an Image Batch Processing script that evolves over five chapters. Each successive version of the script is improved with concepts that are introduced in that chapter.

All of the code in this book was created and tested in Mac OS X 10.6.

Using the Book's Icons

There are four margin icons that are used throughout the book to provide additional information, tips, warnings, or indications of where to find additional information.

Note

Notes highlight useful information that you should take into consideration.

Tip

Tips provide additional bits of advice that make particular features quicker or easier to use.

Caution

Cautions warn you of potential problems before you make a mistake.

Cross-Ref

Watch for the Cross-Ref icon to learn where in another chapter you can go to find more information on a particular topic.

Accessing the Book's Web Site

Several of the longer scripts presented in this book are available for download on Wiley's companion Web site. Visit www.wileydevreference.com for more information and to download the script files.

Part I: AppleScript: The Power of Automation

In This Part

Chapter 1: Introduction to AppleScript Programming

Chapter 2: Workflow Automation with AppleScript

Chapter 3: AppleScript Deployment Options

Chapter 4: Making the Case for Standardization

Chapter 2: Workflow Automation with AppleScript

In This Chapter

Defining workflow automationExploring reasons to automate a workflowUnderstanding why AppleScript is the best language for workflow automation

Before delving into the intricate details of designing, developing, and deploying AppleScript workflow solutions, take a step back and consider the various ways the solution might be used in the future. Such reflection will give you a much richer grasp of the benefits of AppleScript and what it can help you achieve.

A workflow is an ordered sequence of individual steps that are performed together to achieve an overall task. Although the term can refer to any task, in this chapter, only tasks performed on a computer are relevant.

Before you can automate a workflow, you need to abstract the workflow steps from the other unrelated tasks with which they intersect. You must also delimit your focus to avoid being caught up in the folly of automating everything.