From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the reference of every element in array ,the element is cluster

I want to get the reference of element in array. But I only to get the first element reference.无标题.png捕获.PNG 

 

How can I get the reference of element in array I want

xin
Certified LabVIEW Architect (CLA)
Certified TestStand Architect (CTA)
0 Kudos
Message 1 of 7
(2,422 Views)

Hi ziziran,

 

in an array all elements share the same properties, so you only need the reference of the first element…

 

What is your goal?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(2,392 Views)

@ziziran wrote:

I want to get the reference of element in array. But I only to get the first element reference.

 

How can I get the reference of element in array I want


In other words, you can't.

 

You can of course change the values of the individual elements, but not by reference.

0 Kudos
Message 3 of 7
(2,345 Views)

There is probably an easier way to do what you want to accomplish. But since you asked:

The attached example (LV16) shows how to read/write elements in an array of clusters by reference.

 

The bad part is that the reference changes based on the value of "Index Values" property.

So you can't just get a reference and save it. You have to set Index Values each time you 

need to use the reference.

 

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Message 4 of 7
(2,335 Views)

You can get the value of the entire array by reference, replace one element, then set the value of the entire array by reference.

 

But that's not what you asked, so it's basically the wrong question.

 

To do this on an array, it's going to depend a lot on the details and purposes. If you make the reference typed, you probably don't have to deal with variants. This is also the case with clusters, btw.

0 Kudos
Message 5 of 7
(2,324 Views)

@stevem181 wrote:

There is probably an easier way to do what you want to accomplish. But since you asked:

The attached example (LV16) shows how to read/write elements in an array of clusters by reference.


That does seem to work. Not sure if it's supposed to be, or that it's coincidentally working.

 

Might have forgotten the trick, as it is higly impractical to work like that.

0 Kudos
Message 6 of 7
(2,319 Views)

Agree with all the replies here. The array container is a method to contain a series of the same datatype in sequencial order. A method to hold values in memory.

 

It is not meant to be a Front Panel GUI object, to provide for accessing a particular value in a selection of values. This is why the array does not have these properties. There are other ways to do this using the Front Panel objects.

0 Kudos
Message 7 of 7
(2,295 Views)