3.9. Summary

AppleScript's if statement allows you to make decisions and alter the flow of execution based on the result of your decisions. In addition, you learned the following in this chapter:

  • Relational operators allow you to easily compare numbers, strings, and dates. These operators can be expressed with English words or symbols, and they produce a Boolean result of either true or false.

  • The operators and and or allow you to join two Boolean expressions and make more complex decisions.

  • The not operator simply turns a true value false, and a false value true.

  • The if else statement allows you to specify two sets of statements: one that is executed if the result of the test is true, and the other if it is false.

  • The if-else if statement extends the if else statement so that you can specify any of a number of different paths to take based on the results of more than just a single test.

  • A try block encapsulates statements whose failure might otherwise cause a program to terminate. It provides a more elegant way to handle errors.

In the next chapter, you learn how to work with variables, and you are introduced to the built-in AppleScript classes. You also see how to write arithmetic expressions and perform basic conversions between data types. Before proceeding, however, try the exercises that follow to test your understanding of the material covered in this chapter. You can find the solutions to these exercises in Appendix A.

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.