# Keeping Variable When Restarting Program

**URL:** <https://forum.universal-robots.com/t/keeping-variable-when-restarting-program/31243>\
**Category:** Technical Questions\
**Created:** [November 6, 2023, 2:37pm UTC](https://forum.universal-robots.com/t/keeping-variable-when-restarting-program/31243 "2023-11-06T14:37:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snapbean16](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@snapbean16](https://forum.universal-robots.com/u/snapbean16)\
**Post date:** [November 6, 2023, 2:37pm UTC](https://forum.universal-robots.com/t/keeping-variable-when-restarting-program/31243/1 "2023-11-06T14:37:13Z")

</div>

is it possible to store variable values on the fly so that when i restart the program the variable remains the same.  
example would be a counter. so when i restart the program it continues counting from where i left off.  
if it cant be done automatically would it be possible run a program and save the variable on a folder then recall that variable from the folder on program restart?

---

<div class="post-metadata">

**Author:** ![terryc](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/terryc/32/3006_2.png) [@terryc](https://forum.universal-robots.com/u/terryc)\
**Post date:** [November 6, 2023, 5:01pm UTC](https://forum.universal-robots.com/t/keeping-variable-when-restarting-program/31243/2 "2023-11-06T17:01:30Z")

</div>

I think you’re talking about “installation variables.” They persist between runs/power cycles.

Take a look and see if that works for you.

---

<div class="post-metadata">

**Author:** ![snapbean16](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@snapbean16](https://forum.universal-robots.com/u/snapbean16)\
**Post date:** [November 6, 2023, 7:48pm UTC](https://forum.universal-robots.com/t/keeping-variable-when-restarting-program/31243/3 "2023-11-06T19:48:32Z")

</div>

thanks for the reply,  
so i tried the installation variable route.  
lets say for example i make an installations variable called nCount. then i declare that variable as 0 in the installation variable menu.  
then during the program it counts how many runs by adding nCount:=nCount+1.  
when i stop the program the installation variable reverts back to the original 0 that it was declared.  
i would like to say run the program 5 times then stop the robot and when i restart it will start off with 5 already in the variable.  
hope that wasnt too much to understand.

---

<div class="post-metadata">

**Author:** ![efn](https://avatars.discourse-cdn.com/v4/letter/e/35a633/32.png) [@efn](https://forum.universal-robots.com/u/efn)\
**Post date:** [November 7, 2023, 7:18am UTC](https://forum.universal-robots.com/t/keeping-variable-when-restarting-program/31243/4 "2023-11-07T07:18:12Z")

</div>

Installation variables do not revert back to their values declared when created. Those variables keep their value through restarts and program changes. 🙂  
Are you maybe also “declaring” the variable (setting it to 0) in an Assignment in your Before Start or something? Or somewhere else in your program?
