System Alert (sys.alert)
Declaration
choice = sys.alert(text [, autoDismissSeconds, title, button0Title, button1Title, button2Title ])
Parameters
- text
String. The alert message body. - autoDismissSeconds
Number, optional. Auto-dismiss timeout in seconds. Set0to disable auto-dismiss. Default:0. - title
String, optional. Alert title. Default:"Script Alert". - button0Title (Cancel)
String, optional. Title of the default button. Default:"OK". - button1Title
String, optional. Title of the first extra button. Hidden if not provided. - button2Title
String, optional. Title of the second extra button. Hidden if not provided.
Returns
- choice
Integer.0= button0 (Cancel)1= button12= button23= auto-dismissed when the timeout elapses71= SpringBoard crashed while waiting
Description
Pops up a system alert dialog with up to 3 buttons. Blocks all threads until a result is returned. For versions after 2026-01-08, this function yields in a multitasking environment; other threads may run while waiting for user input.
Example
local choice = sys.alert('What are you going to do?', 10, 'Your Choice', 'Cancel', 'Eat', 'Sleep')
if choice==0 then
sys.alert('You chose “Cancel”')
elseif choice==1 then
sys.alert('You chose “Eat”')
elseif choice==2 then
sys.alert('You chose “Sleep”')
elseif choice==3 then
sys.alert('No choice, timed out')
else
sys.alert('SpringBoard crashed')
end