LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mystery offset when using references to build array

Solved!
Go to solution

Hello,

I am trying to update color boxes and text in an array from a subvi using references. Sometimes, everything works perfectly. Other times, there will be some random "default value" boxes between the [0,0] of the array and the intended output.

 

I've created a "simplified" .vi to illustrate the problem. The 4 arrays update from the pass/fail boolean array control. Below is the correct case:

correct.png

Sometimes, the arrays calculated using the reference/index method will be offset by some amount, which is not necessarily the same between the two arrays:

wrong.png

As you can see, the resulting arrays are mostly correct, just shifted off the true [0,0]. I've found that editing a cell in that array will cause this issue. I'm not sure if this is the ONLY thing that causes this issue.

causing error.png

The result after running:

caused error.png

 

Please see attached vi for block diagram. How can I make sure my vi always uses the correct [0,0] index? 

0 Kudos
Message 1 of 4
(2,650 Views)
Solution
Accepted by topic author Amanda.Ison

Despite the name, indexVals does not select an array index.  It postions the selected index to the top left corner of the control.  Apparantly this actually can work for what you want, but fails once you've clicked something.  You should think about preallocating data to the array (based on the size of your pass/fail input, then use Replace Array Subset to update the values.

 

Or you could simplify and do pretty much the same as your bottom loop, just storing to the reference value, instead of a local variable.

Message 2 of 4
(2,608 Views)

Thanks, that explains it.

 

I've also uploaded the new functional version of the vi.

0 Kudos
Message 3 of 4
(2,565 Views)

That pretty much does it.  That true/false condition can be simplified even further.  You can take everything out of the conditional block and use Select nodes with the colors/text as the true false conditions.

 

BTW, the Index Array node can be expanded to return more than one index.  Just click on the bottom and drag down.

0 Kudos
Message 4 of 4
(2,563 Views)