LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rearrange data with correct array size

My VI is trying to rearrange the 2D array that I read from test.xls file, so that each function is get separated with there data in it.

Look over the test.xls file that I have attached. It has 2 columns. Both contains couple functions designated with ) and (. So, ACU_PGM is considered a function. I have rearranged the data so when ACU_PGM (or PGM is selected) the data following it is data for PGM before another function starts, which is KEY and 500 in this case. Same way for all other functions. Each column always ends by );


)ACU_PGM( )CAB_INP(
KEY WRITE
500 50
)ACU_DIA( 3
DM1 0
1010.1 )CAB_CLC(
0 WRITE
PROTECT 50
DM2 3
101.23 0
10 NA
NA )CAB_CRX(
); TEMP_1
3
0
);


The problem with my current design is I am initializing array with 0x0 size, once it gets the 1st function it gets initialized with that same size of that function array for that entire column's fnction, so it want take more elements if 2nd function in same column have more elements like in this case. ACU_DIA has 8 elements but it will only take 2 elements as ACU_PGM has 2 in it.

Please look over the Get_function.Vi only half portion. I have instructions in text in Vi also. I saw that columns are not lookin good after I submit the question so please open test.xlx file to see actual data Thank you.
0 Kudos
Message 1 of 4
(2,752 Views)
Hi Amy,

Could you also attach the Get_Function VI that you mentioned? It's very hard to follow your description without some code behind it. Also, generally speaking you could initialize the array to the max size that you will need first, so you don't run into this problem

Thanks,
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 4
(2,736 Views)
I don't know even though I replied this once it didn't showed in my message sections, so replying again. I have attached Get_function.Vi as zip file with all other files connected to it. There were some problems coming so it didn't accept .llb file. Thank you.
0 Kudos
Message 3 of 4
(2,727 Views)
Hi Amy,

I see what you're talking about. The Insert Array function truncates the data to the length of elements that are already existing in the array. There are a couple ways you could get around this. The easiest way would be to not preallocate a 2D array. Instead, you would just use the Build Array function to keep making the array as large as you need (see attached VI for an example: Get_Function[mod] - written in LabVIEW 7.1). Another way to do it is to keep reallocating memory for a new array everytime you want to "insert" data. This is essentially what the Build Array method will be doing.

Hope this helps!
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 4 of 4
(2,706 Views)