04-28-2022 12:23 PM - edited 04-28-2022 12:25 PM
Is it possible to initialize a blank 2d array?
I initialize one using :
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.
04-28-2022 12:39 PM - edited 04-28-2022 12:42 PM
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:
04-29-2022 05:47 AM
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.
04-29-2022 09:58 AM
Hi,
you could use 2D Array of String ,
Best Regards,
Thank you.
04-29-2022 10:10 AM
@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.