Chapter 3. Making Decisions

You know how to write simple AppleScript programs to evaluate expressions, assign the results to variables, and display dialogs. Now you learn how to make decisions in your programs. Decision making is a fundamental characteristic of any programming language. AppleScript's relational and logical operators provide the means for asking questions, and the if statement and its variants enable you to alter the flow of execution based on the answers to those questions.

Predicting errors that can occur during a program's execution and taking preventive measures to handle them are two components of good programming discipline. The try statement, which allows you to catch errors that might otherwise cause your program to terminate, is also covered in this chapter.

Get Beginning AppleScript® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.