Scripting Additions Guide

CHAPTER 2
Scripting Addition Commands
Command Definitions 25
set prompt to "Please enter password:"
repeat with i from 1 to 4
set dialogResult to display dialog prompt ¬
buttons {"I give up", "OK"} default button 2 ¬
default answer "Joe User" with icon 1
if button returned of dialogResult = "I give up" then
error number -128 --user canceled
else
if text returned of dialogResult = "magic" then
exit
else
if i < 3 then
set prompt to "Password was incorrect. Try " ¬
& i + 1
else
set prompt to ¬
"Password was incorrect. Last Chance!"
end if
end if
end if
end repeat
NOTES
The size of the dialog box is determined by the lengths of the question and
answer strings.
As an alternative to the Cancel button, the user can press Command-period or
the Esc key to cancel a dialog box displayed by the Display Dialog command.
A dialog box can include an icon stored in the script file, the current application
(as specified by a Tell statement), or the System file. If there is an icon with the
specified name or number in the script file, it is used; otherwise, AppleScript
checks the current application; finally, if the specified icon is not found in either
the script file or the current application, AppleScript checks the System file. If
you are using a system that provides Color QuickDraw and the specified icon
is available as a color icon, the color icon is displayed. To add icons to a script
or application file, use a resource tool such as ResEdit.