Include Statements
Sometimes it's helpful to use a set of Vocola definitions in more than one command file. The
Vocola include statement allows you to put such shared definitions in a single file,
and include that file in each of several command files.
For example, many applications need to navigate the file system to find specific files or folders. But speaking
pathnames can be difficult, as can navigating through folder hierarchies by voice. What you'd really like is a
single list of shortcuts to interesting folders, available in any program which needs to navigate the file
system.
Create a file called folders.vch ("vch" stands for "Vocola header") to contain your
list of interesting folders, defined as a Vocola variable:
From file folders.vch:
<folder> :=
( Home = C:\Users\Pat
| Downloads = C:\Users\Pat\Downloads
| Pictures = C:\Users\Pat\Pictures
| Vocola Commands = C:\Users\Pat\Documents\Vocola\Commands
| Program Files ="C:\Program Files"
| Temp = C:\Temp
);
|
With the include statement this list can be used in several
Vocola command files, such as the one for Windows Explorer:
From file explorer.vcl:
include folders.vch;
Folder <folder> = {Alt+d} $1 {Enter}{Tab_2};
|
So for example, saying "Folder Downloads" to Windows Explorer switches to the folder
C:\Users\Pat\Downloads.
The folder list is also useful in a Command Prompt (DOS box), where saying for example "Folder Temp" performs
the command cd "C:\Temp":
From file cmd.vcl:
include folders.vch;
Folder <folder> = 'cd "$1{Enter}"';
|
Last and also useful is the following global command to move quickly
to a specific folder in a "File Open" dialog box:
From file _vocola.vcl:
include folders.vch;
Open | New | Save | File | Attachment | Browse | Directory:
Folder <folder> = $1\{Enter};
|
This global contextual command is active when the window title of any application contains one of the words
shown. For example, when saving an attachment in Microsoft Outlook the window title is "Save Attachment", so
saying "Folder Temp" switches the dialog's current folder to C:\Temp.
Include using a variable filename
The include statement's filename can be varied using references
to environment variables. For example, you might have a different set of interesting
folders at home than at work, and so want to include a different file depending
on which machine you are currently using. Since the environment variable "COMPUTERNAME"
contains the name of your machine, you could say:
include folders_$COMPUTERNAME.vch;
If your work machine were called "Venus" and your home machine were
called "family", you would define your list of interesting folders
in two separate files, "folders_Venus.vch" and "folders_family.vch".