Substituting Actions
So far the spoken words in our alternative sets have been substituted directly
into our keystroke sequences. Actually it is more common to substitute
a different set of actions than the spoken words.
For example, suppose we want "Move Back" to move the cursor left and "Move
Forward" to move the cursor right. We can specify that this way:
Vocola: Move (Back=Left | Forward=Right) = {$1};
Say: Move Back
Sent: {Left}
Say: Move Forward
Sent: {Right}
|
The alternative set (Back=Left | Forward=Right) means you can
say either "Back" or "Forward", but the value substituted on the right hand
side will be Left or Right.
Here's another example. Mozilla's Thunderbird Mailer has several options for
sorting messages. This command allows you to change the sort by saying "Sort
by Date", "Sort by Sender", or "Sort by Subject":
Vocola: Sort by (Date=e | Sender=n | Subject=b) = {Alt+v}s $1;
Say: Sort by Date
Sent: {Alt+v}se
Say: Sort by Sender
Sent: {Alt+v}sn
|
This alternative set allows you to say "Date", "Sender", or "Subject", and
substitutes e, n, or b into the
keystroke sequence. (The keystroke {Alt+v} opens the "View" menu, s
opens the "Sort by" sub-menu, and the final letter chooses the sort option.)
Alternative sets with substitution provide an easy way to define voice shortcuts for items such as files,
folders, URLs, or email addresses. For example, we can define the
variable <address> to contain a list of email addresses and shortcuts to
invoke them:
The command Address <address> allows you to say,
for example, "Address Bill" or "Address Voice Coder" to insert the desired
email address. The list can be modified over time to add new addresses.
An alternative and its substitution (e.g.,
Listen = [email protected]) is actually a mini-command—"when I say this, send
these keystrokes". As with a command, the left-hand side may be an alternative set and the right-hand side may
contain a sequence of actions.