LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Value Property Node for an array element: how do they work?

Solved!
Go to solution

As I was vainly trying to make sense of my recent mistaken Idea Exchang submission (here), I stumbled upon a behavior I am not sure I understand.

Here it goes:

 

Drop an array of numerics on the FP. Show a few elements. The easiest is to grab an "Array - Numeric (Silver)" preformed object, with 3 elements shown.

Now, right-click on the top element and select: Create>>Property Node>>Value

Change that to write on the BD and connect a constant to it, say 1. Run the VI, you get this:

 

Screen Shot 2014-07-30 at 15.11.50.png ===> Screen Shot 2014-07-30 at 15.12.00.png

 

So far so good.

Now do the same for the THIRD element and wire a different constant to the PN, say 3. Run the VI again, you get this:

 

Screen Shot 2014-07-30 at 15.13.29.png ===> Screen Shot 2014-07-30 at 15.13.39.png

 

All right...

I mean, it already doesn't make much sense, but wait for what's coming...

Now, delete the first PN and rerun the VI:

 

Screen Shot 2014-07-30 at 15.14.40.png===>Screen Shot 2014-07-30 at 15.14.49.png

 

Perfectly logical, right? ... not!

At least *I* can't make sense of it and this smells like a bug to me... or a weird feature.

 

Tested in LV 2013 SP1 (62+2 bits) on Windows 7 64 bits.

0 Kudos
Message 1 of 14
(5,305 Views)
Solution
Accepted by topic author X.

You are creating a shortcut to write to the ArrElem.Value property.  The ArrayElement property of an array is a bit funky, it is the last element which has been active.  With only a single PN on your BD writing a value, click in the middle element of the array and then run the VI, repeat for other elements.

 

Message 2 of 14
(5,286 Views)

In the second picture, you didn't enforce the data flow, so the 3rd item in the array (the active one) got set to 3, and then set to 1.
If you enforce the data flow, it looks different.

You will get 3 instead of 1, if you wire like this:

untitled.png

 

 

George Zou
0 Kudos
Message 3 of 14
(5,280 Views)

As Darrin said, it just matters which element is considered the "active" element.  So in your second example, you actually wrote to it a 3 and then a 1 (classic race condition).  You can set the active element with a property of the array (having trouble finding it at the moment).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 14
(5,279 Views)

Makes more sense now (@Zou: I had actually noticed what you illustrate, but I had not try to figure out the reason yet).

This being said, how do I know which element is active programmatically?

0 Kudos
Message 5 of 14
(5,273 Views)
You get the bounds of the ArrayElement, do some math based on the bounds of the array control taking into account the value of the index display. Easy peasy eh.
0 Kudos
Message 6 of 14
(5,260 Views)

The bounds I can get are those of the Array, even if I pull that from a reference to an element.

The only way I can figure to get the Mouse Click location and indeed compute the array element based on some arithmetic.

Other suggestions?

0 Kudos
Message 7 of 14
(5,255 Views)

Put a listbox behind it.

Make sure the row height same.

use the listbox invoke node: point to row, to get the active array index in the mouse down event.

 

 

George Zou
0 Kudos
Message 8 of 14
(5,247 Views)

@zou: that's a workaround.

 

My point is that we get this nice Last Active Element Value PN (Read and Write) but we essentially are left to guess (or work out) which it is. That's fine, but it would seem natural to have some helpers there, such as an "Index of Last Active Element" PN, for instance.

0 Kudos
Message 9 of 14
(5,237 Views)

I actually meant to suggest the ArrayElement.Position property.  I am pretty certain that one works for the individual elements (I kind of assumed the bounds would as well).  Not that I have undertaken this in a long, long time.

0 Kudos
Message 10 of 14
(5,221 Views)