03-22-2012 10:10 AM
So.... I'm trying to play around with references to arrays, specifically references to elements within an array.
It looks like I should be able to just read the value of the array, but because of how I am trying to link LabVIEW & TestStand I am trying to create a utility that will automatically get data back and forth between LV adn TS, where the data types being passed back and forth are completely unknown, and possibly arrays of clusters which have nested arrays of clusters.
So I am trying to walk the LV data structure and go reference into TestStand and get the right data. However, I can't seem to be able to use references to point to specific elements of an array -- see example that I would expect both the top and bottom code to work the same, but they don't.
Any suggestions on what I am doing wrong to get the top and bottom to work the same?
LV2011 code attached
Solved! Go to Solution.
03-22-2012 10:35 AM - edited 03-22-2012 10:40 AM
The array element property node gives you a reference to the element that makes up the array. So if you need to set the properties of a numeric control perhaps to change color, or display format.
It is not a way to get or set the value of a particular array element. To set a particular array element, you need to use Replace Array Subset. To get the value of a particular array element, you use index array.
The indexvalues property node is used to determine what is the first element that is displayed. It changes the value of the indexer to the upper left of the array.
One thing I noticed that I don't know if I knew before was that setting the value property node on the array element reference, will affect the first visible array element. If you turn on highlight execution and play with the array index while it is running, you'll see the resulting array will be different.
03-22-2012 10:36 AM
I can tell you what *is* happening, though I haven't used references enough to know why.
1st, in the last for loop you're multiplying the iteration terminal by itself, not building an array. You will get the values 0, 1,4,9,16 in your 5 iterations.
2nd, your element references are all pointing to the same element. The 1st loop on the bottom is setting the reference to a certain element, which when it exits is the 5th. It appears that Index Values relates back to ArrElem. I bet if you slow down the last loop you'll see the 5th element go through the number set above.
03-22-2012 10:50 AM
@Ravens Fan wrote:
The array element property node gives you a reference to the element that makes up the array. So if you need to set the properties of a numeric control perhaps to change color, or display format.
It is not a way to get or set the value of a particular array element. To set a particular array element, you need to use Replace Array Subset. To get the value of a particular array element, you use index array.
The indexvalues property node is used to determine what is the first element that is displayed. It changes the value of the indexer to the upper left of the array.
One thing I noticed that I don't know if I knew before was that setting the value property node on the array element reference, will affect the first visible array element. If you turn on highlight execution and play with the array index while it is running, you'll see the resulting array will be different.
Although it IS possible, you may not want to do it after you see what is required.
We can get teh value of an array element that is in a control or indicator provided it it the top left element displayed.
This Nugget exploits this fact and demonstated how it can be done. Note: I have not tested that code lately so I do NOT know if NI has broken that behaviour since the writting of that nugget.
Ben
03-22-2012 10:59 AM
Sweet!!!
That nugget is DARN CLOSE to what I am trying to do, and with a few tweaks it should be just dandy.
Thanks
03-22-2012 11:08 AM
Test it first!
It seems few people know how to do that and therefor is NOT part of NI's normal bug testing routine so....
Test it First!
Ben