If you want a notification when something important in your script happens, the display dialog command (Sidebar 4.2) is always a good choice. In a script like the following, for example, careful use of display dialog can let you figure out how many times a repeat statement is running:
set currentIteration to 1 --How many times the repeat statement has run repeat 10 times tell application "Finder" make new Finder window end tell display dialog "Made new Finder window #" & currentIteration set currentIteration to currentIteration + 1 end repeat
Each time that script creates a new Finder window, you'll see a dialog box like the one in Figure 14-2. That way, you can keep track of how many times your repeat statement has run so far—and stop your script if you've seen too many Finder windows appear.
Figure 14-2. This dialog box lets you know that your script has just created a seventh Finder window. And that information, along with $130, will buy you a retail copy of Mac OS X.
Of course, there's one big disadvantage to using display dialog: it interrupts your script's progress. You have to stick around while your script is running, so you can click away each dialog box. And if your display dialog command is inside a long repeat statement, you could be spending the rest of the week just clicking OK.
Luckily, you don't have to use bothersome dialog boxes ...