Ignition Perspective Combine Array Properties

I have 3 array properties of varying length but all of the elements inside are of the same type. How do I combine all 3 into 1 large array property of 16 length?

I would use my Integration Toolkit's flatten() function, like so:

flatten(
	asList(
		{view.custom.CUB_Instances},
		{view.custom.PDC_Instances},
		{view.custom.USS_Instances}
	)
)
1 Like

Would this work if I have arrays inside of arrays?

It isn't recursive. The flatten() function converts a list-of-lists into a list, without going deeper.

Only jython can handle recursion.

I'm pretty sure the script transform to do this would literally just be:

return self.custom.CUB_Instances + self.custom.PDC_Instances + self.custom.USS_Instances

At least, I think that would work.

I wonder if it's worth overloading the expression language + operator to do concatenation of structures like this, only for document/JSON-like things. Probably not worth the risk of confusion, but maybe...

2 Likes

Seems an elegant solution. I like elegant solutions.