Changing initial value of persistent variable without restarting the System

unni2007unni2007 Ladenburg, Germany
Hi everybody,

when I change the initial value of persistent variables such as workobjects in RS, they are not updatet until I restart the controller (using the "apply" button does not work).
Is there an easier way to update the initial values?



  • jeppejeppe world
    edited December 2019

    one way to update the value of persistent variable is to run program code in which new value is assigned to the variable.

     PERS num nTest:=1;
        PROC Temp()

  • graemepaulingraemepaulin New Zealand ✭✭✭

    Have you tried right click -> refresh as below?

  • unni2007unni2007 Ladenburg, Germany
    Sorry for the late reply and thanks for the two suggestions, both of which work great!
    In my case, however, the problem was that the persistent variables were defined in two different tasks, where they were both assigned a value.  So obviously the variables were not updated, even though I changed them using FlexPendant...

    Best Regards
  • graemepaulingraemepaulin New Zealand ✭✭✭
    edited January 8

    The Multitasking manual states:

    A persistent variable is global in all tasks where it is declared.

    The persistent variable must be declared as the same type and size (array dimension) in all tasks. Otherwise a runtime error will occur.

    It is sufficient to specify an initial value for the persistent variable in one task. If initial values are specified in several tasks, only the initial value of the first module to load will be used.

    So as long as the above is followed the value of the variable will change in all tasks - in RobotStudio you will probably have to refresh each task to see it update.

Sign In or Register to comment.