Skip to content

Local variable & Global Variables difference

Examples are valid for:
TMflow Software version: 1.76.6300 or above.
TM Robot Hardware version: All versions.
Note that older or newer software versions may have different results.


Global Variables #

The Global Variables can be accessed by clicking Global Variable in Robot Setting.

Global Variable values can be accessed or changed in different projects.

As shown in the figure below, an integer type Global Variable is declared as a.

The newly added Global Variable will appear in the project’s variable list, and it will be represented as a Global Variable starting with “g_“.

※ If, for example, users create a global variable with a name of ‘a’, this will be displayed by TMflow as “g_a”, indicating that it is a global variable.

The global variable “g_a” defaults to a value of zero. If the SET node increments the value of “g_a” by one each time it is executed, after running the project 66 times the value of “g_a” will be 66.

At this point, any other project that accesses “g_a” will get the value 66 for the variable.

IMPORTANT:

Global variables will not be re-initialized when the system shuts down. They will retain their value.

 

Local Variables #

Local Variables can only be called in a single project, and their effective range is only within the project that created these variables.

Variables are created through the Variable tab, at the top of the TMflow interface. In this page, a single variable or array variable can be declared and assigned a value.

According to the different data formats, TMflow provides six types of variables: int, float, string, double, bool, and byte. The meaning of the variables is shown in the table below. If no value is assigned, a string initial value of empty, and the remaining variables default to 0.

The newly added local variables will appear in the project’s variable system, and begin with “var_” to represent local variables in the variable system. Users can use dropdown to filter available variables in the list, and sort variables in the list with the buttons of reverse alphabetical, alphabetical, or chronological. Click the Batch Delete button to select multiple variables to delete. The exclamation mark denotes unused in the flow.

After clicking the newly added variable, the declaration of a variable can be performed. For example, the integer type variable TM_Robot=0 can be declared.

In addition to declaring a single variable, variable arrays can also be declared. The array declaration method is to set the name of the array variable and the size of the array. The default size is 0. As an array with size 10 and name Array is declared, the Array {0, 0, 0, 0, 0, 0, 0, 0, 0, 0} can be obtained. If users want to obtain the first value of the array, Array[0] can be called in calling the array SET Node.

To edit a variable or an array, select the item and click the pencil icon. For variables or arrays, the data type is not editable, and for arrays, the array size is not editable, either. Users can edit variables or arrays with naming staring with “var_ only.

Powered by BetterDocs