Defining Variables
Defining Variable Terms
If you want to re-use an alternative set in several different commands,
you can assign it to a variable. For example, we can create a variable called
<direction> to hold the alternatives "Left | Right | Up
| Down", and use it in a command:
Vocola: <direction>
:= Left | Right | Up | Down;
Move <direction>
= {$1};
Say: Move Left
Sent: {Left}
Say: Move Down
Sent: {Down} |
This command is equivalent to the second command in
the previous section, allowing you to move the cursor in one of four directions.
The following command defines the variable <number>, and
is equivalent to the third command in the previous section:
Vocola: <number>
:= 1..40;
Move Down <number> = "{Down $1}";
Say: Move Down 1
Sent: {Down 1}
Say: Move Down 12
Sent: {Down 12} |
This moves the cursor down a given number of lines.
Finally, we can write our general-purpose arrow-key command (move a given number of steps in any direction) using both
the <direction> and <number> variables:
Vocola: <number>
<direction> = "{$2 $1}";
Say: 3 Left
Sent: {Left 3}
Say: 10 Down
Sent: {Down 12} |
Note that a variable reference may appear earlier in a Vocola command
file then the definition of that variable. |
This page is (c) Copyright 2002 by Rick Mohr,
and was last modified on May 11, 2002.
|