From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-18-2017 09:26 AM
Hello,
I'm trying to build a program in which I have a table and the user can click on whichever radio button he wants and it will add the corresponding array to the table.
My arrays are created at the beginning with an arbitrary amount of memory (which is larger than expected to be loaded) and a for loop while loading the file counts the actual number of elements in the file itself. I wish to use SetTableCellRangeVals to put the data in rows since the data is not uniform. Does the array length has to match the number of rows I open even though I explicitly define how many needed rows to put (the array itself is longer than the amount of data I want to put in the table)?
Thanks in advance for the help.
02-18-2017 06:00 PM
You know? I don't understand what you afre trying to do and what you want to know!
You have a table and an array of data in memory that you wanto to put on the table, ok... so what's the file for?
Next, if "data not uniform" means elements of different data type then you cannot use SetTableCellRangeVals.
Anyway, the array lenght must not match the number of rows in the table: you may have a larger array with respect to the cell range; you'll get an error if the number of cells in the range is larger than the array elements.
02-19-2017 07:47 AM
Hello Roberto,
Even without understanding you've helped me with that matter. However, now I'm stuck with another problem regarding the table.
I have two arrays that I want to fill in a table, each in 1 column and x number of rows (which is the same number of rows for both arrays). In order to do that, I have 2 radio buttons where each is supposed to create a column and the x number of rows and fill them with their associated array (one radio button for cycleIndex array and one radio button for CTime array).
I use the following code:
GetCtrlVal (showDataPanelHandle, DataPanel_CycleNumData, &CycleNumberData);
GetCtrlVal (showDataPanelHandle, DataPanel_CorrectTimeData, &CTimeData);
if (CycleNumberData == 1) {
InsertTableColumns (showDataPanelHandle, DataPanel_TABLE, -1, 1, VAL_CELL_NUMERIC);
InsertTableRows (showDataPanelHandle, DataPanel_TABLE, 1, numOfElements, VAL_CELL_NUMERIC);
SetTableCellRangeVals (showDataPanelHandle, DataPanel_TABLE, MakeRect(column,1,numOfElements,1), cycleIndex_maccor, VAL_ROW_MAJOR);
column++;
}
if (CTimeData == 1) {
InsertTableColumns (showDataPanelHandle, DataPanel_TABLE, -1, 1, VAL_CELL_NUMERIC);
InsertTableRows (showDataPanelHandle, DataPanel_TABLE, 1, numOfElements, VAL_CELL_NUMERIC);
SetTableCellRangeVals (showDataPanelHandle, DataPanel_TABLE, MakeRect(column,1,numOfElements,1), CTime, VAL_ROW_MAJOR);
column++;
}
where "column" is the number of column I want it to put in (meaning - if just one of the radio button is selected, put the array in the first column and when both are chosen, put the cycleIndex in the first column and the CTime in the second column. the column variable is initiated to 1);
When I use this code, while filling only one array, it works fine. When I want to put them both, it creates 2 columns, one with all zeros and one with both arrays, one after the other. I don't know what I'm doing wrong.
Thanks for the help.
02-19-2017 01:40 PM
Well, supposing you start with the table empty, after you create the first column and corresponding rows you do not need to add rows anymore, since as you can read in the help for InsertTableColumns:
This function creates a new cell for each column in the table.
Since you create columns at the end of the table and rows at the beginning, by looking at your code I expect the following:
if (CycleNumberData == 1) { Create a column at the end of the table Create rows at the beginning of the table Fill the column } if (CTimeData == 1) { Create a column at the end of the table Create rows at the beginning, shifting existing cells down Fill the initial portion of the column }
So I'd expect to have twice as rows as you would, one column filled from the first cell and the other starting from position numOfElements
I don't know why you get such a strange layout, but I'd start by cleaning the code this way:
Read both radio buttons Create the appropriate number of rows and columns Fill-in the column(s)
Finally, you may find useful VAL_TABLE_COLUMN_RANGE (x) macro to fill the column: the macro automatically expands to the whole-column rect struct (there is also a corresponding VAL_TABLE_WOW_RANGE (x) macro which you do not need this time).