LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert into 2D array error

 

I dont understand this error. I want to insert a string into a 2d string array at each row and column 0. 

 

govindsankar_2-1760598381877.png

 

 

But it is showing these errors and I dont understand the errors. First of all, insert into array : more than one index input is wired. I want to insert at a certain row and column, so if i am not able to wire both, how will i do that. Secondly the broken wire is when I tried to connect a string variable into a new element/sub array option which means i should be able to insert an element. The error goes away when I put a build array to the string output. But I am not trying to insert an array. I am trying to insert a string variable. Both these errors doesnt make any sense. Can anyone kindly help me. Thank you.

 

0 Kudos
Message 1 of 4
(158 Views)

Hi,

as an insert fuction changes the overall dimension of the 2D array, you cannot insert a single element, because it will cause undefined values, you always need to insert a whole row or column. 

Editing a single element is only with the Replace subset function possible.

A possible solution for you would be to collect the data for a whole row / column and insert this. Take care that the dimension of the 1D array matches to the dimension of the 2D array where you want to insert it.

 

Another way would be to initialize an empty array with the final dimension and then use the replace subset function. I think this way would also be more memory efficient. Of course this requires to know the final dimension of the array.

MECSO_0-1760599407334.png

 

_________________________
using LV 2025 Q3
0 Kudos
Message 2 of 4
(144 Views)

Hi govindsankar,

 

you're using LabVIEW for so long and still don't understand basics?

 


@govindsankar wrote:

I dont understand this error. 


Error: you indexed the 2D array for exactly one element: you need to insert that single element - you cannot insert this way!

How should LabVIEW insert a single element into the 2D array? Should it insert row-wise or column-wise?

 


@govindsankar wrote:

I want to insert a string into a 2d string array at each row and column 0. 


So you want to insert a new column: leave the row input unwired and only wire a "0" for the column input. Then you can insert the new column into the 2D array...

Why are there so many sequence structures? Still don't understand that "THINK DATAFLOW!" mantra?

Do you really think that creating two random numbers will need 1ms (or more)? The result of this time measurement will most often result in "0 ms"...

 

Btw. you should follow MECSOs advice on using an array of pre-defined size and use the ReplaceArrayElement function instead...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(143 Views)

If 1 input is wired you can insert a column or row, and if 2 is wired you can input a separate element, you can't input a 2D array at a specific point.

The easiest solution if to loop through your replacement and replace them one by one.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 4
(78 Views)