Function Library and $using
The Vocola Function Library is a collection of functions useful for voice commands, organized into classes and
implemented as a Vocola Extension. To get a feel for what's there you can:
- Browse the Function Library Documentation online.
- Read the same information from the installed help file, by saying "Vocola Library" or right-clicking the
Vocola tray icon and choosing "Function Library".
- See the previous section, Function Calls, for examples of library functions in action.
Function, class, and namespace
Every library function is part of a library class, and every library class is part of
the Library namespace. As described below you can often call a function
without specifying its class and namespace. But if desired you can always call a function unambiguously using
its full name, where the namespace and class name prefix the function name.
For example, the SwitchTo library function
is part of the Main library class, and is called
using its full name in this example:
Use Explorer = Library.Main.SwitchTo(explorer);
|
The $using statement
Because full names can be cumbersome Vocola has the $using statement, which can allow
you to omit the namespace and class name when calling a function. Here is the same example
with $using:
$using Library.Main;
Use Explorer = SwitchTo(explorer);
|
Note that $using statements must appear first in a command file, before
other Vocola statements.
Base $using set
Because it can be tedious to add the same $using statement to many command files
Vocola defines a default base using set, with the option to customize it. As
described in Options Panel, the base using set lets you specify a set
of $using statements to be implicitly included in every Vocola command file and header
file. The default base using set is:
$using Library;
$using Library.Main;
$using Library.Pointer;
|
With this base using set you can omit the ‘Library.’ namespace
prefix from all library function calls, and can omit the class name prefix when calling functions in the
Main and Pointer library classes. The upshot is that by
default our example command needs neither a full name nor a $using statement and can
be written simply as:
Use Explorer = SwitchTo(explorer);
|
Note that a
$using statement only affects function calls in
the same command file. If a file
includes a second file it is unaffected by
any
$using statements in that file.