LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make initial array's element blank

Is it possible to initialize a blank 2d array? 

I initialize one using : 

PULSEWannabe_0-1651166359120.png

but it has 0 as initial value, and my program send 0 on the first run

what I want is a blank array that keeps accumulating my input number into array, so the first element is my first input number, not 0

example of input number that accumulates : a random number generator that generates number every 10s that go into a build array function that concatenates with the old number.

 

0 Kudos
Message 1 of 5
(1,448 Views)

Your array is empty (as can be seen by the disabled element at [0,0]. This is the default value of the element.)

 

If your first accumulated element is later is zero, you are doing something wrong, but we would need to see your code to see what's wrong. (To accumulate random numbers, a 1D array might be more suitable.)

 

You can resize your array container to make things more clear:

 

altenbach_0-1651167739294.png

 

Message 2 of 5
(1,441 Views)

There are two different things here

1) The value shown when you display an empty array. If you enter a value to an I32, say "5" and then use this to create the array constant, it will show "5" for empty elements

2) When indexing array indices where the elements do NOT exist (i.e. in your case with an empty array) the default value of the datatype will be returned, because there's literally nothing to reference. So even if you do the step in 1), the default value of a non-existing array value will still be zero. In a way, the visual representation of the "5" for "empty" elements is misleading.

Intaris_0-1651229236617.png

 

0 Kudos
Message 3 of 5
(1,391 Views)

Hi,

you could use 2D Array of String ,

 

Emna20_0-1651244300172.png

 

Best Regards,

Thank you.

0 Kudos
Message 4 of 5
(1,370 Views)

@Emna20 wrote:

you could use 2D Array of String ,


This does not solve the OP problem, because they get an undesired value=0 as first element later, then blame the completely innocent diagram constant. Using strings (without fixing the core of the problem, such as e.g.  a race condition or other dataflow issue) would do exactly the same thing and they would just get an empty string as first array element. A string is also not suitable to hold random numbers at the full binary precision/limitation..

 

An empty array of strings is not the same as an array of string with one empty string as element.

 

So the solution would be to fix the problem code. They should also be aware that container size != array size.

0 Kudos
Message 5 of 5
(1,362 Views)