LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

appending arrays in FOR loop

I'm very new to Labview and trying to get some code working.  I have some data that I'm reading 128 bytes at a time in a FOR loop.  I would like to build up that data so that at the end of the loop I have an array of 1024 elements.  I have tried using build array with concatenate turned on and a single input but it just results in the data in my destination array being overwritten each time the loop executes. 

 

Is there a VI that does what I want directly, or what is a way to get what I'm after?

 

Thank you.

0 Kudos
Message 1 of 5
(2,973 Views)

I am guessing that a shift register is the missing element in your attempt, although I often use the reshape array route myself. 

 

BuildArrayExample.png

Message 2 of 5
(2,970 Views)

Or...

 

 

 

Message Edited by smercurio_fc on 10-24-2009 08:49 PM
Message 3 of 5
(2,958 Views)
Thank you.  I was missing the shift register.  Being a C programmer, I expected the array to persist in my loop.  I did not realize I had to do something special to save the value and re-introduce it for the start of each iteration.
0 Kudos
Message 4 of 5
(2,924 Views)

phabib wrote:
Thank you.  I was missing the shift register.  Being a C programmer, I expected the array to persist in my loop.  I did not realize I had to do something special to save the value and re-introduce it for the start of each iteration.

Good! 

 

There are many subtle things that look what we knew from C but are diferenent. Yes a static local is like Shift Register IF it is not initialized.

 

Please read (when you have some time) this Nugget on a code structure we often use in LabVIEW (called an Action Engine) to share data across multiple threads without having to go to explicitly using mutexes.

 

The other thing I should make sure you hear early on is "controls/indicators" and locals are NOT like locals in C. In LV the wires are un-labeled variables.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 5
(2,917 Views)