Persistent Variables: Difference between revisions
Created page with "In some cases, it is useful to be able to store variables that are kept even when the robot is turned off or the program is changed. If, for example the total number of cycles of a specific program should be tracked, the counter should not be reset every time the robot is turned off. Instead, the value should be stored such that it can be used to count the program cycles over the robot’s lifetime, and not only during a single period of being turned on. Defining a vari..." |
(No difference)
|
Revision as of 14:18, 11 August 2025
In some cases, it is useful to be able to store variables that are kept even when the robot is turned off or the program is changed. If, for example the total number of cycles of a specific program should be tracked, the counter should not be reset every time the robot is turned off. Instead, the value should be stored such that it can be used to count the program cycles over the robot’s lifetime, and not only during a single period of being turned on. Defining a variable as ‘persistent’ makes it possible to store their values in between sessions. This is not restricted to simple number Variables but is also availabe for position variables.
Definition in a robot program
One way to define a persistent variable is to add it to a robot program like a normal variable. The only necessary additional step, is to check the checckbox labeled 'persistent' in the command definition in the program editor.

When trying to add a variable that already exists, there are four special cases users should be aware of:
- The existing variable is a normal variable & the persistent checkbox is NOT checked : The value of the existing variable will be overwritten.
- The existing variable is a normal variable & the persistent checkbox is checked: The value of the existing variable will be changed to the value defined in the command. The variable will also be set to persistent.
- The existing variable is a persistent variable & the persistent checkbox is checked: If the existing variable is persistent, the state of the checkbox is irrelevant. The value of the variable will also NOT be changed. Otherwise the store command would have to be manually removed from a program, to not defeat the purpose of a persistent variable.
This is the recommended way to add persistent variables, as it makes sure that variables, that are used in a program actually exist, and persistent variables are also available in the simulation of a robot.
Definition from the 'Program & Variable' area
The other way to define a persistent variable, is the ‘Program & Variable’ Section in the Footer area of the iRC. This section contains a list of all Variables that currently exist in the robot’s memory. To add a variable, click on the ‘+’ button in the respective list, depending on the kind of variable that should be added. After the variable was added, it can be renamed, and the values can be set to the desired values by clicking on it. To apply the Changes either press on the ‘Apply Changes’ button, or simply press ‘Enter’.

Changing the name of a variable does only change the name in the robot’s memory. All references to it must be changed manually, to make sure programs continue to work as expected. It is therefore NOT recommended to change the name of a variable that is already in use.