The Dialogs library contains functions used to create user dialogs.
Description: Allows you to send message text to the user's device. Once the user confirms receipt of the message, an empty string is returned.
Syntax: Dialogs.alert(message)
Example: The following code expects a string input. It checks the length of the string, and if it is fewer than 8 characters, the message "Login must be longer than 8 chars" is displayed on the device screen:
// Check login length if(String.length(login) > 8 ){ // Too short, ask again Dialogs.alert("Login must be longer than 8 chars"): }
Description: Allows you to send a message to the user's device. The user is given two selection options, ok or cancel (the text for each is specified). If the user chooses ok, the result of the function is true. Otherwise, the result is false.
Syntax: Dialogs.confirm(message,ok,cancel)
Example: The following example displays the string "Confirm your order" on the device display, and assigns a value of true to the variable named "confirm" if the user presses the accept key, and a value of false if he presses the soft1 key.
// Get order confirmation var confirm = Dialogs.confirm("Confirm your order", "Yes", "No");
Description: Allows you to send message to the user's device prompting for input. Default input text may be provided.
Syntax: Dialogs.prompt(message,defaultInput)
Example: The following code displays the string "Enter phone number" on the device display, along with an input element that contains a default value of "650-". When the user presses the accept key, the value is assigned to the variable named "phone".
// Get phone number var phone = Dialogs.prompt("Enter phone number", "650-");
3.22.248.208