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
What it Does
Displays a simple modal panel containing a message and up to three buttons which the user may click. Returns the title of the selected button in the variable it
.
When to Use It
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 three different alternatives.
The 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 ask command.
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 "Account" from list the unique items of myListOfChoices
Example:
answer "What would you like to drink?" from list ["Coffee", "Tea", "Beer", "Water"] allow multiple default "Coffee"
Syntax
answer {panelType} {Options}
Options:
{prompt | body | message}
prompt
with reply1 {or reply2 { or reply3 {or reply4}}}
[title | titled] titleExpr
[timeout | time out ] {after | in} duration
icon iconName
[default {answer} | answer] defaultSelection
{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 (rightmost) 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.
The order in which the prompt, replies, title, timeout, and icon 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).
For more information about the Answer
command, see Using Ask and Answer.
ask
What it Does
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.
When to Use It
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.
Example
ask "Enter your name:"