From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bug in replace array.

replace array.png

front.png

 

Should we expect this type of result in "Array"?

 

My guess it should be the inverted version of "Array 2".

 

 

----------------

 

I've corrected it by placing shift register on the tunnels.

 

Please remove the post sorry.

0 Kudos
Message 1 of 4
(2,344 Views)

The behaviour is entirely expected.

 

On your first iteration, you replace the 0th element of the initialised array. On your second iteration, you replace the 1st element of the initialised array, rather than the result of the replace array primitive from the previous iteration.

 

Change the tunnels of the for loop to shift registers, and you'll pass the result of the previous iteration to the current iteration.

 

If you change your initialise constant to True, or the array length to an odd number (but not both), you'll easily notice that when the for loop finishes, only the last element will be changed.

 

You can figure out 'bugs' like this (read: shortcomings in your code) via Highlight Execution and probing.

---
CLA
0 Kudos
Message 2 of 4
(2,331 Views)

@gagikk wrote:

My guess it should be the inverted version of "Array 2".

 

I've corrected it by placing shift register on the tunnels.


With a shift register, you won't get an inverted version, both output arrays will be the same.

 


@gagikk wrote:

Please remove the post sorry.


No, posts like this should not be removed. Many new users will learn from this discussion in the future.

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

It's a classic mistake to manipulate arrays without shift registers, we've all done it. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 4
(2,283 Views)