User Interaction in SenseTalk Scripting
You can write SenseTalk scripts that prompt for information during runtime. The following commands allow your SenseTalk script to interact with the user by displaying or requesting information.
Answer Command
Behavior: The answer command displays a simple modal panel containing a message and up to four buttons which the user may click. The from list option lets the user choose from a longer list of possible answers. As a modal panel, script execution is paused while the panel is displayed.
Use the answer command when you need to display short to medium-length messages in a modal panel, or to solicit input from the user in the form of a choice between two or more different alternatives. The basic answer command is ideal for situations where the user must make a yes/no or continue/cancel type of decision. For more complex choices use the from list option, or for open responses use the ask command.
Returns the title of the selected button or selected item from the list in the variable it.
Syntax:
answer {panelType} OptionsOptions:
{prompt | body | message} prompt
[title | titled] titleExpr
with reply1 {or reply2 {or reply3 {or reply4}}}
[timeout | time out] {after | in} duration
icon iconName
[default {answer} | answer] defaultSelection
{from} list listOfChoices
{allow} multiple
An optional panelType of information, question, warning, or error may be specified. The exact implementation of each panel type is up to the host application, but typically shows a related icon in the panel.
The prompt is an expression whose value will be displayed as the primary text in the panel. TitleExpr is the title which will be displayed in a larger font at the top of the panel.
Reply1, reply2, reply3, and reply4 are the labels that will be shown on the buttons at the bottom of the panel, with reply1 being the default button. The number of buttons shown will match the number of reply strings specified in the command. If no replies are specified, a single button labelled OK will be included.
If the timeout option is used, duration specifies the length of time (in seconds, if not explicitly specified) that the panel will be displayed waiting for user input. If the user doesn't respond to the panel within that time, it will be dismissed automatically. In that case, the variable it will be empty, and the result function will be set to a value indicating that the panel timed out.
The icon option may be used to supply a different icon to be shown in the panel. If it is used, iconName may be either the name of a known system icon, or the full path to an icon file.
If a listOfChoices is given, all of those choices will be displayed in the main part of the panel. The user may select one before clicking the "OK" button. If multiple is also specified, the user will be able to select more than one of the choices which will then be returned as a list.
The order in which the options are specified is flexible, and all of them are optional (except that at least one option must be supplied).
After execution of the answer command, the variable it will contain the title of the button that was clicked (or empty if the panel's timeout elapsed). If a listOfChoices was presented and the default button was clicked, it will contain the choice or list of choices that was selected by the user.
For more information about the answer command, see Using Ask and Answer.
Example:
answer "Great! You got " & pctRight &"% correct!"

Example:
answer "Go on?" with "Yes" or "No" title "DECIDE"

Example:
answer "How do you feel?" with "Great!" or \
"Okay" or "Really Lousy" title "Greetings!"

Example:
answer "What would you like to drink?" from list ["Coffee", "Tea", "Beer", "Water"]

Example:
answer "Account" from list the unique items of myListOfChoices

Related:
Ask Command
Behavior: Displays a modal panel containing a prompt string and a text entry field in which the user may type a response. A default response may be supplied. Returns the user’s answer in the variable it. As a modal panel, script execution is paused while the panel is displayed.
Use the ask command when an answer is required from the user which is not from a predetermined list of choices. Use the ask password command to request input that is hidden while it is being typed.
Syntax:
ask {password} OptionsOptions:
{prompt | question} question
[title | titled] titleExpr
[with {answer} | answer] presetAnswer
[hint | placeholder | place holder] placeholder
[message | body] {text} message
{with} [buttons | button {label{s}] label1 {[and | ,] label2}
[timeout | time out] {after | in} duration
icon iconName
Example:
ask "Enter your name:"

Example:
ask "How do you feel?" title "Greetings!"

Example:
ask query with defaultAnswer titled "Please Answer"

Example:
ask password "Enter the secret code"

The text value of question is displayed as the prompt above the input field in the panel. TitleExpr is the title, which will be displayed in a larger font at the top of the panel. The string value of the presetAnswer expression is displayed in the answer field as the default response. If placeholder is given, the placeholder value will be displayed in the answer field when it is empty and not selected. The message text will be displayed in the panel below the title.
If label1 (and optionally label2) are specified, they define the buttons on the panel, otherwise two buttons are presented at the bottom of the panel: Cancel and OK. If the user clicks the OK button (or presses return) the value in the answer field is put into the variable it. If the user clicks the Cancel button the value of the variable it is set to empty, and the result function returns "Cancel".
If the timeout option is used, duration specifies the length of time (in seconds, if not explicitly specified) that the panel will be displayed waiting for user input. If the user doesn't respond to the panel within that time, it will be dismissed automatically. In that case, the variable it will be empty, and the result function will be set to a value indicating that the panel timed out.
The icon option may be used to supply a different icon to be shown in the panel. If it is used, iconName may be either the name of a known system icon, or the full path to an icon file.
The order in which the options are specified is flexible, and all of them are optional (except that at least one option must be supplied).
After execution of the ask command, the variable it will contain the value entered in the field (or empty if the panel's timeout elapsed).
For more information about the ask command, see Using Ask and Answer.
Related:
Put Command
Behavior: When no destination container is specified, the put command displays text in the standard output.
Use the put command in this way when you want to display status information during a script without putting up a modal panel like the answer command would. The put command is also very popular during the development of a script for displaying the current value of variables at different points in the script.
Syntax:
put {expr {, expr ...}}
Example:
put "Successfully loaded file " & fileName