Vocola Information Pages   by Rick Mohr (this page updated May 31, 2003)
 
 Introduction
 Using Vocola
 Language Tutorial
    Keystroke Commands
    Quotes And Whitespace
    Using Alternatives
    Defining Variables ->
    Substituting Actions
    Capturing Dictation
    Optional Words
    Function Calls
    Built-in Functions
    Defining Functions
    Contextual Commands
    Include Statements
    Comments
    Example File
 Command Sequences
 Install Vocola
 Vocola Versions
 Converting DVC Files
 Troubleshooting
 Support
 Wish List
 My RSI Story
 Voice Resources
 

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 (c) Copyright 2002-2005 by Rick Mohr.