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.

Certification

cancel
Showing results for 
Search instead for 
Did you mean: 

Initialize Array then Replace Items vs. Build Array

The CLD Success package example solutions tend to initialize and array, which is fed into a for loop, then replace the array elements withing the for loop.  I have always built such arrays using the "Build Array" function and starting the shift register off with an empty array.  Is the Initialize/Replace structure prefered?


Thanks.

 

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 1 of 2
(3,211 Views)

The Initialize and Replace is more efficient since it does not require more memory to be acquired each time you add an element.

 

But if you are working in a FOR loop, I would just use the Autoindexing Tunnels.  They can be conditional if you need that as well.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 2
(3,210 Views)