10-23-2006 11:45 AM
10-23-2006 01:34 PM
10-23-2006 02:44 PM
10-23-2006 06:51 PM
10-24-2006 05:05 PM
zskillz,
You are correct. LabVIEW is just like C++/CVI in this respect. If you create the full array before your loop and then use your loop to fill in the values, this will run faster than if you dynamically build the arrays inside your loop using the build array function. This is usually only important if you are working with very large arrays or you are calling this routine very quickly and the timing has to be as fast as possible. Most people use the "Initialize Array" function to create the pre-allocated array before their loop and use the "Replace Array Subset" function to insert values into this array.
LabVIEW does try to be smart though and will do this for you in some circumstances. One example of this is if you create a for loop and wire a constant to the iteration count terminal (like 10) and then wire a constant inside the for loop to the edge and enable auto indexing. In this instance, LabVIEW knows that your loop is going to execute exactly 10 times and you will add one element to your array for each iteration. LabVIEW is smart enough to pre-allocate an array of size 10 before your loop runs.
Justin D
Applications Engineer
National Instruments