07-25-2018 02:45 AM
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
Solved! Go to Solution.
07-25-2018 04:08 AM
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
07-25-2018 04:39 AM - edited 07-25-2018 04:44 AM
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?
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
07-25-2018 05:03 AM
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.
07-25-2018 05:07 AM
Like [(a,b1),(a,b2),(a,b3)] and [(a,b)]
But i could have misinterpret it totally...
07-25-2018 05:09 AM
as i said, was not quite sure i understood correctly.
lets wait for lara to update.
07-25-2018 05:56 AM - edited 07-25-2018 05:59 AM
oh perfect thank you!! jwscs you interpreted everything right! 🙂
07-25-2018 06:10 AM - edited 07-25-2018 06:11 AM
07-25-2018 07:49 PM
I misinterpreted it...
07-26-2018 04:21 AM
@cy... wrote:
I misinterpreted it...
no worries