Function Calls
Not everything can be accomplished with keystroke sequences -- Vocola commands
can also include calls to
built-in functions,
user-defined functions,
and
extension routines.
Here are two simple examples of calling built-ins:
Die Die = GoToSleep();
Hit Down = ButtonClick(2,1);
|
The first example puts NaturallySpeaking in sleep mode when you say
"Die Die". The second example clicks the mouse when you say "Hit Down".
The function HeardWord is useful for writing a command which
invokes another command. Any command recognized by NaturallySpeaking may
be invoked this way, whether it was defined in Vocola, NatLink, or the
Dragon Macro Language.
For example, maybe you'd like to say "Kill Word" to delete a word rather than
using the built-in NaturallySpeaking command "Delete Next Word", but you don't
want to take the time to figure out the exact keystroke sequence. This command
does the trick:
Kill Word = HeardWord(Delete, Next, Word);
|
A command's actions can be a mix of keystroke sequences and function calls.
For example, this command performs a "paste" at the current mouse location (saving
you a mouse click):
Paste Here = ButtonClick() {Ctrl+v};
|
Function arguments aren't always constant -- you can use a reference to a variable
term as an argument to a function call. For example, this command allows you
to copy a window's contents to either NaturallySpeaking or Emacs, by saying
"Copy to NatSpeak" or "Copy to Emacs":
Copy to (NatSpeak|Emacs) = {Ctrl+a}{Ctrl+c} AppBringUp($1);
|
Here the result of the first variable term (NatSpeak|Emacs) is passed
to the function AppBringUp to bring up the desired application.
Finally, a function argument can be built by concatenating more than one action.
For example, the "Back" and "Forward" buttons in a Web browser
use by convention the keystrokes Alt+Left and Alt+Right. In Lotus Notes these
keystrokes only work when passed via the SendSystemKeys function:
Vocola: Go (Back=Left | Forward=Right) = SendSystemKeys( {Alt+$1} );
Say: Go Back
Sent: SendSystemKeys( {Alt+Left} )
|
When you say "Go Back", the function argument {Alt+Left}
is constructed by combining the characters {Alt+, the reference
$1, and the character }