LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array from Case structure

Solved!
Go to solution

I need some help building an array (in a For-loop?) with a case structure in it.

 

My program reads an input table with two colums, where the second one contains either single numbers or a range of numbers (f.e. 1..x). One case of my structure takes a row in which a range of numbers is written and outputs an 2D array, where the number in the first column is fix and the second colum contains x rows with the numbers from 1 to x. The other case is for the rows with single numbers and creates an 1D array, which is just the original row from the old table. I need to combine these arrays in a 2D array where the rows are put underneath each other in a loop which takes row by row.

 

Would be very grateful for some help!!

Thanks, Lara

0 Kudos
Message 1 of 10
(3,883 Views)

I don't think you can build an array with a case structure in it.

 

if you want to extract a row from the table, can consider creating a property node (selection start) from the table control, in which will give you a cluster of row and column index(s). use the row to index the table control to obtain the selected row's data. using string functions to extract your x's and for loop it to build your 2D array for the first case. other case can use resize array add a dimension to it.

 

also, the string length logic should be in between the selection start + index, and for loops within cases

CY (expired CLAD)
0 Kudos
Message 2 of 10
(3,858 Views)
Solution
Accepted by topic author la.rie

hi lara,

welcome to the forum.

since you are new, i'd recommend you to skim through this nice writeup https://forums.ni.com/t5/Community-Documents/Unofficial-Forum-Rules-and-Guidelines/ta-p/3536495

 

regarding your problem... i am not sure i understood you correctly,
but this is what i came up with... it's ugly, but i think this is what you wanted to do?

something-something-table.PNG

 

i am sure altenbach/crossrulez/ben/gerdw/bob/and-all-you-other-gurus will jump in with a two function equivalent 😉

 

regards and i hope it helps


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
Message 3 of 10
(3,850 Views)

Based on what I get, Lara have a 2 column multirow table and would want to update a 2D array with numbers corresponding to the row selected. The 2nd column have strings that represent either a number or a range (start...end). In case the 2nd column's selected row is a range, build a 2D array from start to end while maintaining first column value. In case of single number, build a 2D array but only with the row's entry.

CY (expired CLAD)
0 Kudos
Message 4 of 10
(3,842 Views)

Like [(a,b1),(a,b2),(a,b3)] and [(a,b)]

 

But i could have misinterpret it totally...

CY (expired CLAD)
0 Kudos
Message 5 of 10
(3,838 Views)

as i said, was not quite sure i understood correctly.

lets wait for lara to update.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 6 of 10
(3,837 Views)

oh perfect thank you!! jwscs you interpreted everything right! 🙂

0 Kudos
Message 7 of 10
(3,828 Views)

Hi jwscs,

 

you asked for it… 😄

 

check.png

I don't claim it's an improvement to use the Ramp function with it's DBL array output, but it's one loop less…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 10
(3,817 Views)

I misinterpreted it... Smiley Indifferent

CY (expired CLAD)
0 Kudos
Message 9 of 10
(3,791 Views)

@cy... wrote:

I misinterpreted it... Smiley Indifferent


no worries


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 10 of 10
(3,778 Views)