User Variables


*Tip:  There are three types of variables in vTask:

    1) User Variables, such as %foo.   These are your variables.
    2) System Variables, such as {clipboard}.   These are read-only values.
    3) Environment Variables, such as %PATH%.   These are read-only operating system values.




General Overview of vTask Variables
 

If a script is anything more than a trivial job, it will most likely need to use variables. Variables are generally a "holder" for information. You can also think of them as a representation of other data. If you are not sure about the concept of variables, please refer to a basic programming documentation, there are many online tutorials concerning variables. Wikipedia has a good description of variables.

Here's a simple example of a variable in action:





In vTask, there are 3 types of variables:

      1) User Variables

      2) System Variables

      3) Environment Variables

Additional features of vTask variables:


*Tip:  See the Tools - Options screen for information regarding the persistence of variables with "Reset variables between runs".



Setting Variables with Action results
 

In the screen image below is an example of saving a name into a variable. The User Prompt action will ask the user for a value, and save it into the variable called "%answer" (it can be called anything). "%answer" can then later be used anywhere inside of another command, where it will be replaced with the value that the user typed. The input prompt and the properties for saving the value to a variable appear as follows:





*Tip:  There is no distinction made in vTask between numeric and text variables. They can be used interchangeably.



Setting Variables with Create/Set Action
 

There is no need to "declare" a variable in vTask before using it. Below is an example of using the System - Set Variable action to set a variable:




If you want to perform a math expression such as an increment:


  %foo = %foo + 10  


...use the following System action:




Erasing Variables
 

To erase a variable (set it to empty), use the System - Set Variable action with the "Set to Value" field empty.




Deleting Variables
 

To delete a variable, please refer to the Delete Variable System Action.


Variable Arrays
 

vTask provides a form of array storage for user variables. The basic syntax of an array is:   %variable [ index ]
Arrays in vTask are not 0-based or 1-based; you can start storing at any offset.

There are various ways to create and access array items, as illustrated in the following examples:



You can also fill up an array inside of a loop, and access the individual items later in your script: