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. Set0
to 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
= button1
2
= button2
3
= auto-dismissed (timeout)
71
= SpringBoard crashed
Notes
Pops up a system alert dialog with up to 3 buttons. Blocks all threads until a result is returned.
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