Copyright 2002-2015 Rick Mohr

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.

Note that references to variables such as <direction> are case sensitive; referring to <Direction> would not work.

The following command defines the variable <number>, and is equivalent to the third command in the previous section:

Vocola: <number> := 1..99; 
        Move Down <number> = {Down_$1};

Say: Move Down 6   Sent: {Down_6}

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 Left  Sent: {Left_10}

Note that a variable reference may appear earlier in a Vocola command file than the definition of that variable.

Rich alternatives

A variable, range, or alternative set may appear as an alternative. For example:

<letterKey> := a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z;
<key> := <letterKey> | (Space|Space Bar)=" " | 0..9;

Here the variable <key> is defined to have all the members of the variable <letterKey>, the range 0..9, and the alternative set (Space|Space Bar).