![]() |
Vocola Information Pages
by Rick Mohr (last modified March 24, 2001) |
Alternatives and ReferencesFor example, you might want to be able to say either "Switch View" or
"Next View" to switch between views in an application:
Here the alternative term (Switch | Next) allows you to say either. In many cases you want the actions invoked by a command to depend on
which alternative was spoken. For example, you might want to move
the cursor in one of four directions by saying "Move Left", "Move Down",
etc.:
Here the "$1" specifies that the first variable term should
be substituted. So, when you say "Move Left" the value of the first
variable term is "Left" and the keystrokes "{Left}" are sent.
Often you will want to specify a range of numbers as alternatives in
a command. This can be specified concisely in Vocola, as in the following
example:
Here the syntax "1..10" is shorthand for "(1|2|3|4|5|6|7|8|9|10)". On the right hand side we substitute the spoken number (e.g. "6") to construct the syntax for a repeated keystroke ("{Down 6}") and we have a command which moves the cursor down a specified number of lines. In real life it's very useful to control the arrow keys by saying simply
"1 Down", "3 Left", "6 Up", etc. Here's how to write it in Vocola:
This command has two variable terms. On the right-hand side the second
term (which direction to move) is substituted first and the first term
(how many times) is substituted second, to create the necessary keystroke
syntax. The quoted space character causes the space keystroke to appear
between the two resolved references.
This web page (http://people.ne.mediaone.net/rmohr/Vocola/AlternativesAndReferences.html) was last modified on March 24, 2001. The contents of this page are (c) Copyright 2000-2001 by Rick Mohr. All Rights Reserved. See Copyright Information for more details. |