Add variable to structure tag in IDL

133 views Asked by At

I was wondering if someone knew how to add more values to a structure variable in IDL?

For example, if we have the structure 'struct'

struct = {structname, x:[1,2,3], y:[10,11,12]}

And I specifically wanted to add [4,5,6] to x, something like:

struct.x.add([4,5,6])

How would I do this?

1

There are 1 answers

0
mgalloy On

If you made x a list instead of an array, you could do this easily:

struct = {structname, x:list([1, 2, 3], /extract), y:[10, 11, 12]}
struct.x->add, [4, 5, 6], /extract

It is more difficult, and less efficient, to use arrays for lists of things that change length. You definitely can't do it with named structures because the only way to do it is to change the definition of the structure, which you can do only if you replace one anonymous structure with another.