Why do we care about variables?Let's say I want VoxCommando to tell me the time. When writing my command, my watch tells me it's 9:00 AM. Obviously I don't want to write a command rule that says:
"The time is 9:00 AM".
Instead, I will use a standard variable that always returns the current time.
"The time is
{ShortTime}."
This happens to be a variable that is already created for us to make our lives easier. We don't have to create it ourselves, we can simply look up the variable name and put it to use. In fact, there are a variety of built-in time and date variables, depending on how we want to format that information.
Consult the Variables page of the wiki to see a full list of built-in variables. Other ways to find variable namesWhen you are building your commands in the macro builder (
LCB), there are several tools to help you find the variable you're looking for:
* When entering values in relevant fields, the auto-complete will show a list of common variables when you start by typing "{"
* The
parameter helper tool in the LCB also gives you access to variable names.
* If you look up
action descriptions, the descriptions explain what variables are relevant for the action you are trying to use.
Commonly encountered variablesYou can learn more about these and other variables by using the program, looking at existing commands in your configuration, consulting the wiki, and watching various video tutorials.
*{LastResult}
*{PF.1},{PF.2}, etc.*{Match.1}, {Match.2} etc.
* {#M}, {#P}
*{1},{2}, etc. (Technically, these symbolize "payloads", not variables. There is an important distinction, but the notation in your command is similar so I include the reference here.)
Here's a fun built-in variableDid you know there's a variable in VC that serves as a random number generator? (integers only!)
{Rnd.1.100} will return a random integer value between 1 and 100. You choose the number range.
Create your own variableThe action
Results.SetVar allows you to create your own variable name and pass it a value, which you can then use globally -- not only in that specific command, but any command.
This means you should be careful not to use the same variable name to represent different things in different commands!Your custom variable can then be accessed as
{var.yourvarname}These variable values are volatile and are stored only as long as VC is running. If you wish to store an enduring value (e.g. an API key or IR code), you can store that information in a
map table and access it using map variables.
PluginsNote that some of the plugins also use their own special variables. These are not listed on the main variables page of the wiki, but they are documented in the plugin's action descriptions within VoxCommando, and elsewhere in the wiki documentation.
In SumVariables store information that can change over time, based on changing conditions.
- The {ShortTime} value changes because time moves on.
- {LastSpoken} will always return the text of the most recently recognized speech.
You might find it helpful to think of {curlybrackets} as a placeholder in your command macro. {curlybrackets} will be replaced with the information that we ask VC to retrieve at that given point in time.
In other words, the value can
vary depending on the conditions we set and what we ask VC to do. ("Ahhh. Variable -- I get it now." ;-p)