# Set installation variable and create it if it does not exist

**URL:** <https://forum.universal-robots.com/t/set-installation-variable-and-create-it-if-it-does-not-exist/1641>\
**Category:** Java\
**Created:** [February 19, 2018, 8:42am UTC](https://forum.universal-robots.com/t/set-installation-variable-and-create-it-if-it-does-not-exist/1641 "2018-02-19T08:42:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon42905246](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon42905246](https://forum.universal-robots.com/u/anon42905246)\
**Post date:** [February 19, 2018, 8:42am UTC](https://forum.universal-robots.com/t/set-installation-variable-and-create-it-if-it-does-not-exist/1641/1 "2018-02-19T08:42:44Z")

</div>

Continuing the discussion from [Read variables set by assignment](http://forum.universal-robots.com/t/read-variables-set-by-assignment/1603/9):

Correct me, if my reasoning process is wrong.

InstallationNode creates a section of code in script file, when the file is created or changed. My intention is to create a URCap, where I can set up some configuration options. These options, however, will not be updated, until I change the program and click “Save” icon. How would I achieve the desired effect, i.e. user changes option in InstallationNode and runs the program without modifying it.

I thought about keeping configuration in Installation variables values and updating them from InstallationNode.  
How would I do that? I figured, that Installation is called Persisted in API and I can filter one by name. But I don’t see the method to update it.

---

<div class="post-metadata">

**Author:** ![anon42905246](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon42905246](https://forum.universal-robots.com/u/anon42905246)\
**Post date:** [February 19, 2018, 10:04am UTC](https://forum.universal-robots.com/t/set-installation-variable-and-create-it-if-it-does-not-exist/1641/2 "2018-02-19T10:04:55Z")

</div>

> [@generateScript method called twice for the same ProgramNodeContribution](http://forum.universal-robots.com/t/generatescript-method-called-twice-for-the-same-programnodecontribution/1582/2):
>
> In general, the code should be able to handle multiple calls to the generateScript method. It can be called when program is saved, or typically when the program is played. At play instance, it could happen, if the user double-taps (debounce) on the Play button. Note: generateScript is only called, when all nodes in a program context return true on their respective isDefined calls.

Ok, so I didn’t realize, that there is something going on backstage. “generateScript” is called also when program is run. That is great. Now I can be sure, that my variables will be set. My fears were unfounded.

Therefore my case is closed.

---

<div class="post-metadata">

**Author:** ![anon46802796](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@anon46802796](https://forum.universal-robots.com/u/anon46802796)\
**Post date:** [April 22, 2018, 7:05pm UTC](https://forum.universal-robots.com/t/set-installation-variable-and-create-it-if-it-does-not-exist/1641/3 "2018-04-22T19:05:19Z")

</div>

I’m trying to understand how to assign these variables, even if I still didn’t get if is possible only for _InstallationVariables_ or all.

I’m following the _IdleTimeProgram_ example, I got my variables list and I can select them in a combobox, can you clarify how I can assign to this variable a value form user input? I’m using the scriptWriter which calls the _getSelectedVariable_ method, which again get the variable form the model (_model.get()_). But when I run the script, both my _InstallationVariables_ and _scriptVariables_ have same previous values.

Best regards,

Matteo Timossi @anon46802796

---

<div class="post-metadata">

**Author:** ![anon6912891](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@anon6912891](https://forum.universal-robots.com/u/anon6912891)\
**Post date:** [September 14, 2020, 9:27pm UTC](https://forum.universal-robots.com/t/set-installation-variable-and-create-it-if-it-does-not-exist/1641/4 "2020-09-14T21:27:19Z")

</div>

Did you manage to solve the problem?
