02-03-2013 08:56 PM - edited 02-03-2013 08:58 PM
The pop-up menu item Show Last Element behaves differently for 1D arrays displayed horizontally or vertically with multiple elements visible.
The horizontal display shows the last k elements where k is the number of elements visible when k < N. The vertical display only shows the last element and k-1 empty elements.
See attached VI for a simple example. The VI was written in LV 2012 and saved back to LV 8, but not tested in any earlier version.
The LV Help is not very helpful. Under Adding Elements to Arrays it says: "Right-click the index display and select Advanced»Show Last Element from the shortcut menu. The index display changes to the index value of the last element in the array."
This is the behavior of the vertical display but not the horizontal display.
Generally the horizontal display behavior is what I want, although for the Add Elements to Array process the vertical behavior may be better.
Is this a bug (inconsistent behavior)? A feature? An unintended consequence of something else?
Lynn
02-03-2013 10:27 PM
Hi johnsold,
Make the index of both the array 0 then run your program.
Now horizontal array shows 4th element & vertical array shows 10th element.
02-04-2013 01:27 PM
@johnsold wrote:
Is this a bug (inconsistent behavior)? A feature? An unintended consequence of something else?
I agree, this looks inconsistent.
@Ranjeet_Singh wrote:
Make the index of both the array 0 then run your program.Now horizontal array shows 4th element & vertical array shows 10th element.
What are you trying to say here? You are just repeating the instruction #1 on the front panel of the posted VI, then repeating what the image above already shows.
02-04-2013 01:35 PM - edited 02-04-2013 01:36 PM
@altenbach wrote:
@johnsold wrote:
Is this a bug (inconsistent behavior)? A feature? An unintended consequence of something else?
I agree, this looks inconsistent.
@Ranjeet_Singh wrote:
Make the index of both the array 0 then run your program.Now horizontal array shows 4th element & vertical array shows 10th element.
What are you trying to say here? You are just repeating the instruction #1 on the front panel of the posted VI, then repeating what the image above already shows.
I would call it expected behavior. After all LabVIEW arrays are (Row, Col.....) you see the last element in the last displayed row. This should help keep the dimension order cleanly in your mind even if you display a row vertically.
02-04-2013 01:54 PM
I would also call this inconsistent behavior. The last displayed row should contain the last row in the array.
02-04-2013 02:38 PM
Two to one for inconsistent behavior.
I think I understand what your are saying, Jeff, but I thought that unlike MATLAB, LV considers 1D arrays independent of direction of display. Under that interpretation it seems like the same values shoud be displayed regardless of direction.
Lynn
02-04-2013 03:09 PM - edited 02-04-2013 03:15 PM
@johnsold wrote:
Two to one for inconsistent behavior.
I think I understand what your are saying, Jeff, but I thought that unlike MATLAB, LV considers 1D arrays independent of direction of display. Under that interpretation it seems like the same values shoud be displayed regardless of direction.
Lynn
well, not exactly. What happens when you add dimention to a 1D array or remove dim from a 2D? a 1D array is a row. Implementing a transpose with a vertical row display is problematic. And arrays must be rectangular since they are flat in memory. That being said. I wouldn't cry if the behavior changed.
02-04-2013 03:14 PM
I will not call this inconsistent behavior because it is consistent. It uses the same formula in either case: Last Index = Length - #cols.
While consistent, I do consider it wrong. The formula I would choose is Last Index = Length - 1, for all dimensions. Show Last Element should IMO put the last element in the upper left position. I understand the appeal of the horizontal behavior, but I do not really like the idea of counting the number of visible rows and columns to determine the index of the last element. Either way, it should be Length-1 or Length - Max(#rows,#cols), but not Length-#col
What I would like is the optional ability to disable in addition to graying out the out-of-bound controls.
02-04-2013 03:24 PM
If you want the index of the last element, use Array Size - 1.
Often when I use Show Last Element, I want to see the values of the last element and several preceeding it. I would prefer the lower right position as the one containing the last element. If I only want to see one element at a time, I will set the display to show only one element. Of course that case has no inconsistency.
Lynn
02-04-2013 03:43 PM
Hello all,
I filed CAR 389834 on this behavior. It is inconsistent behavior between the vertical and horizontal display. Since it is a 1D array, it should be only a visual difference and it should not be row vs column. I linked this thread to the CAR, but can you give me a bit of context of how this behavior affects your application? It seems like a cosmetic issue with low impact, so if it is impacting you more severely, I would be interested to hear about it.
As always, thank you for reporting these issues!
Jeff Peacock
Product Support Engineer | LabVIEW R&D | National Instruments