RobotStudio event

Changing initial value of persistent variable without restarting the System

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?

Cheers
Kris

Comments

  • jeppe
    jeppe
    edited December 2019
    Hi,

    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()
            nTest:=2;
            stop;
        ENDPROC

  • Have you tried right click -> refresh as below?


  • 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
    Kris
  • graemepaulin
    edited January 2020

    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.