Universal Robots Forum

Initialize list of x size in URScript


I would like to be able to initialize a list of X size in URScript.

What is it?

A method of creating a list of a predefined size with elements of undetermined value. For example, in C++, you would do something like this to initialize a blank array of type int that is 10 elements long: int foo[10].

Why is it needed?

Creating an array to hold data in URScript is PAINFUL. If I wanted to initialize an array that can hold 50 numbers in URScript, I would have to do the following: array = [0, 0, 0, 0, 0, 0, 0, 0, 0, … 0, 0]. This is not only super tedious, but can be a source of error if I accidentally type the wrong number of zeros. I know there are some work arounds to this, but I have not found one that doesn’t seem goofy or convoluted. Thank you.

1 Like