1.9. Exercises

  1. Modify the expression from your first program so that it calculates the circumference of a circle with a radius of 1.48. As a hint, recall that the circumference of a circle with radius r is expressed by the formula 2πr. Have the program perform the entire expression evaluation (that is, don't calculate 2r yourself!).

  2. Write a program that poses the following question: "Do you think this is a great book?" Have two buttons labeled Yes and No, with Yes as the default.

  3. Add a comment to the beginning of the program you created in Exercise 2 that describes the purpose of the program.

  4. Add the following description to the program created in Exercise 2: "A program to ask a profound question!"

  5. Modify the display dialog example (used earlier in this chapter) that presented the three color choices to make "Red" the default button.

  6. Can you alter the order of the display dialog parameters? Experiment and see.

  7. The beep command takes an optional numeric parameter that specifies the number of times to beep your system. For example, beep 2 causes two beeps. Modify the last program in this chapter to beep 3 times before the dialog is displayed.

  8. The AppleScript say command can be used to speak text. The command is followed by the character string to be spoken. Write an AppleScript program that speaks the phrase "Programming in AppleScript is fun."

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.