Substituting Actions
Substitutions
So far the spoken words in our alternative sets have been substituted directly
into our keystroke sequences. Actually it is more commonly useful to substitute
a different set of keystrokes 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. The Netscape 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=r | Subject=s) = {Alt+v}o $1;
Say: Sort by Date
Sent: {Alt+v}oe
Say: Sort by Sender
Sent: {Alt+v}or |
This alternative set allows you to say "Date", "Sender", or "Subject",
and substitutes "e", "r", or "s" into the keystroke
sequence.
Another common use of alternative sets with substitution is when you want
to pick from a long list of specific items such as files, folders, or email
addresses. For example, we can define the variable <EmailAddress>
to contain a list of email addresses and shorthands to invoke them:
Vocola: <EmailAddress>
:= ( Bill = bsmith@mediaone.net
| Dragon = info@dragonsys.com
| Voice Coder = VoiceCoder@yahoogroups.com
);
Address <EmailAddress>
= $1 {Enter};
Say: Address Bill
Sent: bsmith@mediaone.net{Enter}
Say: Address Voice Coder
Sent: VoiceCoder@yahoogroups.com{Enter} |
The command "Address <EmailAddress>" 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. Dragon = info@dragonsys.com
) 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. However, the left-hand
side may not contain variables or ranges, and the right-hand side may not
contain references. |
|