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
 

Function Calls

Function Calls Not everything can be accomplished with keystroke sequences -- Vocola commands can also include calls to built-in functions and user-defined functions.

Here are two simple examples:

 Vocola: Die Die = GoToSleep(); 
         Hit Down = ButtonClick(1,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:

 Vocola: 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):

 Vocola: Paste Here = ButtonClick(1,1) {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":

 Vocola: 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 "}"


This page (c) Copyright 2002-2005 by Rick Mohr.