The alertsheet statement displays an alert sheet (attached to the current window) with a message and one or more buttons. Note: with the introduction of OS 11, Big Sur, sheets no longer appear to slide down from the title bar, but open a dialog centered on the active window.
Parameters
This statement has three parameters:text – is the message to display in the alert.
option – The name of an option that modifies the operation of this statement. See below for descriptions of each option. The option can be specified in either upper or lower case.
value – The new value for this option.
Description
The alertsheet statement displays an alert sheet (attached to the current window) with a message and one or more buttons. Unlike a floating alert however, the alertsheet is only associated with the form to which it is attached. This means you can access other windows while the dialog is still being displayed and only the form it is attached to is made inactive until the alertsheet is dismissed. In its simplest form, it displays the message with one button, Ok.
alertsheet "The operation is complete"
The appearance and operation of the dialog can be modified by adding one or more pairs of option/value parameters to the alert statement, like this:
alertsheet message,option1,value1,option2,value2,option3,value3,option4,value4
Each of the available options are described below.
Use this option to define one or more custom buttons. The option value should be a comma separated list of buttons to include in the alert. The buttons must be listed in reverse order – the first button listed will be on the right and will be the default button if the Enter or Return key is pressed. This example displays an alert with three buttons.
alertsheet "Do you want to continue?","Buttons","Yes,No,Maybe"
if info("dialogtrigger") = "No"
stop
endif
if info("dialogtrigger") = "Maybe"
if rnd() > 0.5
stop
endif
endif
...
...
...
The procedure pauses until one of the buttons is clicked. As shown above, the procedure can use the info(“dialogtrigger”) to find out which button was clicked.
Note: Pressing the Enter or Return key is the same as clicking the first button (the button farthest to the right). If the alert contains a Cancel button, pressing the ESC button is the same as clicking on the Cancel button. If there is no Cancel button, the ESC key is ignored. Be careful not to add a space in the button list unless you want it to be part of the button name.
You can also specify each button separately, like this:
alertsheet "Do you want to continue?","Button","Yes","Button","No","Button","Maybe"
Notice that in this case the option name is button, not buttons.
This option allows you to display additional text in the alert. This additional text is displayed in a smaller, non-bold style.
alertsheet "Operation complete!","TEXT",info("selected")+" records were processed."
Apple has three styles for alerts – Warning, Critical, and Informational. Use the style option to set the alert style you want (the default is Warning).
alertsheet "Gadzooks! Negative balance","style","critical"
You can abbreviate the style down to a single letter.
alertsheet "Gadzooks! Negative balance","style","c"
You can also use ! for critical and ? for informational.
alertsheet "Gadzooks! Negative balance","style","!"
Note: At the time this was written, Apple displays Warning and Informational alerts exactly the same. Critical alerts are displayed with a yellow triangle icon.
Alerts normally appear with the Panorama icon in the upper left hand corner. You can specify a different icon with the icon option. Any image file can be used.
alertsheet "Gadzooks! Negative balance","icon","~/Pictures/DollarSign.png","style","!"
See Also
History
Version | Status | Notes |
10.0 | New | New in this version. |