LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to an array by reference does not write the data to proper index

We need to write to a specific position of an array from a subVI. We only have the reference number to the array control and the index to which we want to write.

Our implementation sets the index value to the desired position using a property node. A second property node sets the value of the array element (ArrElem.Value). This works fine if just one array element on the front panel is visible. However, if multiple elements (columns/rows) are visible, the position of the value that we set depends on the position of the last user interaction. To be more precise, the index at which the value appears is Desired Index plus Index of last user interaction (see attached example).

We would like to know if there is a solution to this problem or if we are doing something wrong.


Message 1 of 6
(3,275 Views)
As the online help says the IndexVals property is "index of element displayed in the top left corner of the array" and not the index of element you're gonna write.
If I understood well, maybe you should try the Selection Start[] and Selection Size[] properties.
0 Kudos
Message 2 of 6
(3,264 Views)
You use the Values property to get the actual array and then do a Replace Array Element and then write the modified array back with the same property. As mentioned, the IndexVals only sets the array element that is displayed/
0 Kudos
Message 3 of 6
(3,262 Views)
Just to clear things up. We know that IndexValues just sets the element as the top left one, but we thought it would also set it as the active one where one would change the value using the Value property. But as we found out that is not the case. So the question remains if somebody knows how to change the element one writes to when using the ArrElem.Value property in a predictable way.

Thanks for the suggestions, using the StartSelection[] and SizeSelection[] didn't work and using replace element also doesn't work for us since
we want to do this for arrays of different dimensions.
0 Kudos
Message 4 of 6
(3,255 Views)

According to this, this should have been fixed in 8.0.

A workaround for 7 is to set the number of rows and columns to 1, change the element, and then change it back, but this will look weird if you see the array.


___________________
Try to take over the world!
0 Kudos
Message 5 of 6
(3,242 Views)
You can also disable FP updates while altering the array to hide tha fact that you're messing around with the array display properties, but if you have a lot of UI action going on, this may be quite annoying as all other UI updates will be delayed.....

If you're doing multiple operations on a single array, disabling the UI updates can speed things up considerably too (in LV 6.1 at least).

Kludgy, but it is possible.

Shane.

Message Edited by shoneill on 11-29-2005 04:17 PM

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 6 of 6
(3,224 Views)