# Safe variables with an variable name

**URL:** <https://forum.universal-robots.com/t/safe-variables-with-an-variable-name/19975>\
**Category:** URScript\
**Created:** [March 18, 2022, 2:56pm UTC](https://forum.universal-robots.com/t/safe-variables-with-an-variable-name/19975 "2022-03-18T14:56:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon32996938](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@anon32996938](https://forum.universal-robots.com/u/anon32996938)\
**Post date:** [March 18, 2022, 2:56pm UTC](https://forum.universal-robots.com/t/safe-variables-with-an-variable-name/19975/1 "2022-03-18T14:56:11Z")

</div>

Hi folks,  
due to the missing function of saving a position in a variable in Polyscope V3.15 I am trying to solve this for an easy setup later.

I thought to use global variables, so the main program can use those variables also. They are all the same syntax. An example is pos\_xx. xx is the variable which defines the position.

By asking the user which pos he wants to change I have the pos as an variable. But how can I use this variable to save a position on this variable?

```auto
    local pActualTCP = p[0,0,0,0,0,0]

    xTargetPos = request_boolean_from_primary_client("Is the TCP on point?")  

    if xTargetPos:

        iPosToChange = request_integer_from_primary_client("Which Position do you want to change?")
        sPosToChange = to_str(iPosToChange)

        sPosToChangeValue = "pos_" + sPosToChange
        popup("Is " + sPosToChangeValue + " right?") 

        get_actual_tcp_pose(pActualTCP)

        global 'HERE IS THE PROBLEM' = pActualTCP
        
        popup("That went smooth", title = "Success")
        halt

    else:
        popup("The program will be terminated", title = "Error", error = True, blocking = True)
        halt
    end

```

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [March 18, 2022, 7:10pm UTC](https://forum.universal-robots.com/t/safe-variables-with-an-variable-name/19975/2 "2022-03-18T19:10:31Z")

</div>

Create an array to store the positions and use the operator’s input as the index.

Pose\_list[input]=pActualTCP

Now you just get to struggle with the fact that UR still hasn’t implemented a way to initialize an array of a set size easily, nor do they have a dynamically sizable array.
