LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I'm struggling inserting element into a 1D array as my input changes.

So I would like to insert numbers (inputs) into the appended array. Let's say I am increment my inputs by 1 starting from 0, I would expect to see in my array [0,1,2,3,4,5,...] as

shown below. However, it's not the case. What am I doing wrong here? How can I fix this?

GRCK5000_1-1677866961063.png

P.S: I don't want to use event structure

 

 

 

0 Kudos
Message 1 of 4
(958 Views)

The loop runs as fast as it can. So it starts flooding the array with the value of the control, 0...

 

Put a wait in the loop.

 

Or use an event structure in the loop, so you only add a value to the array if the control value changes.

0 Kudos
Message 2 of 4
(946 Views)
  • Your program is a prime example of code that will make your computer run out of memory very quickly. Why don't you create an indicator for the array size and for the iteration terminal to see what's happening.
  • If you just want to count, you should use integers (blue, not orange).
  • If you want to limit the input to a certain range, change the "data entry" properties of the control. No need to coerce later.
  • You are not inserting numbers into an array, but appending numbers to an array.
  • You might want to add a [add] button that would trigger the appending of the control value to the array. (An event structure for a value change of the numeric control might not be suitable, because maybe you want to occasionally add two of the same values in a row.
0 Kudos
Message 3 of 4
(923 Views)

@GRCK5000 wrote:

 

P.S: I don't want to use event structure

 

 

 


You will need to add a boolean control (ie button) with a case statement to meet your requirement. Something like this...

 

Frozen_0-1677873215580.png

 

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
Message 4 of 4
(918 Views)