LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In place structure with array element replacement uses wrong index

Solved!
Go to solution

Hi,

 

I'm using the in place element structure and noticed strange behaviour: if I replace elements in a subVI and then in the calling VI, the index is off by one in the calling VI, most of the time. I've seen one or two runs where the index was correct. Searching the forums yielded other problems with the in place structure but not exactly this one.

 

Attached are a couple of VIs demonstrating the problem and some screenshots.

 

0 Kudos
Message 1 of 4
(3,722 Views)

I was easily able to reproduce your issue.  It always works the first time it is opened, then develops some +1 behavior after that.  I do not know why the case structure is causing the problem, but I found two solutions, yeah, well, work arounds anyway.

 

1. Place either a "Value" property node or local variable for Row inside the default case (simpliest solution)

2. Put the In place element structure in a subVI.  (causes a useless extra subvi)

 

either method yielded proper results.  If you choose 1, I would make sure that you comment why you did it, so in 5 years when you revisit this (and NI has fixed the bug), you will remember!

Cheers,

Paul


Paul
Message 2 of 4
(3,684 Views)
Solution
Accepted by topic author Jarimatti

It appears you have run into a LabVIEW optimization issue.  It appears that the Row value is getting incremented in your subVI and is somehow making it back to the main VI.  If you place an Always Copy in front of your reset_selections.vi call, I was not able to get the error to occur.  There have been a couple of bugs similar to this.

 

You may want to add another Always Copy in front of the call to reset_pages.vi, but I never got the problem to occur without it.

 

Mod.png

 

I have attached the modified VI as well.

 

 

Message 3 of 4
(3,664 Views)

Matthew Kelton wrote:

It appears you have run into a LabVIEW optimization issue.  It appears that the Row value is getting incremented in your subVI and is somehow making it back to the main VI.  If you place an Always Copy in front of your reset_selections.vi call, I was not able to get the error to occur.  There have been a couple of bugs similar to this.

 

You may want to add another Always Copy in front of the call to reset_pages.vi, but I never got the problem to occur without it.

 


Thanks, I didn't even think about optimization in this case. But it sounds like it, as the previous reply mentions making a subVI from the in place structure as a workaround for this issue.

 

Anyways, I replaced the structure with the Replace Array Subset VI. I don't even know why I didn't use it in the first place: I must have been obsessed with in place structures

0 Kudos
Message 4 of 4
(3,651 Views)