Accessing Properties and Methods of Array or a Cluster Elements

Updated Oct 25, 2023



  • LabVIEW

  • I have an array ora a cluster and I would like to programmatically change the properties or call methods corresponding to the elements. How do I do this?
  • I am using an array of a named numeric data type (such as an enum or ring), but, when I set the elements of the array to a variable of the same datatype, it appears that nothing changes or the wrong data is passed. How can I edit the Strings[] property of the named numerics directly so that my strings are copied to every element of the array?

Note: When editing the properties of elements in an array, you will be editing the properties of ALL elements in that array. For example, if you have an array of Boolean buttons and you set the color of the Boolean to blue, all of the buttons will be blue. This is because all elements in an array share the same properties. If your data structure needs to store different properties for different elements, you should consider using a cluster.

To programmatically change properties or call methods for elements in an array ora cluster:
  1. Obtain a reference to the array or cluster of interest. To create a reference, right click on the terminal from the block diagram and select Create»Reference.
  2. Obtain a reference to the array or cluster element. Right click on the Array Reference, select Create>>Property Node»Reference or  Pass the reference into a property node.
  3. Specify the  element type. At this point, LabVIEW doesn't know what the element type is, only that it is an element of an array. You need to tell LabVIEW the element type and this is done by using the To More Specific Class function located in the Application Control Palette on your Array Element reference. To create a reference for the target class, you can right click the target class terminal on To More Specific Class and select Create>>Constant. This will create a Generic constant. Click on this constant and navigate the drop-down menu to find the class corresponding to the data type in your array. (Most of the common data types can be found under Generic>>GObject>>Control.)
  4. Access or set the properties of your elements. Place a property or invoke node on the block diagram and wire the output of To More Specific Class to that node. You now have access to the individual properties or methods available for that type.
The following image demonstrates how to use this method to programmatically change the text stored in the elements in a string array: