06-22-2013 09:23 AM
I hope you can help me find why GetTableCellvalue is failing.
I'm getting "The control is not the type expected by the function".
int calPanelId = LoadPanel(PARENT, "gui_main.uir", CAL_PANEL);
Point p;
p.x = 1;
p.y = 1;
double val = -1.0;
int status = -1;
status = GetTableCellVal(calPanelId, READY_TAB_TABLE, p, &val);
READY_TAB_TABLE is a table, according to the uir file:
gui_main.h:#define READY_TAB_TABLE 2 /* control type:
table, callback function: (none) */
I would appreciate any help you can give me.
Thanks,
Randy
Solved! Go to Solution.
06-22-2013 10:06 AM
Sorry, should say GetTableCellVal not Value.
06-22-2013 11:36 AM
Hi, some hopefully useful questions...:
1) Is your panel CAL_PANEL a child panel? You call it PARENT, but if it is a parent panel PARENT should be equal to zero, see the help on LoadPanel
2) you should add some error handling, i.e. check for the value of calPanelId...
3) If the name of your panel is CAL_PANEL then I would assume that your table should be called something like CAL_PANEL_TABLE... Or did you modify the include file yourself?
4) What is the cell type of the table you want to read?
06-22-2013 01:36 PM
Thanks for the quick reply.
"1) Is your panel CAL_PANEL a child panel? You call it PARENT, but if it is a parent panel PARENT should be equal to zero, see the help on LoadPanel"
PARENT is set to zero.
"2) you should add some error handling, i.e. check for the value of calPanelId..."
Added check for calPanelId. It is 1 after call to LoadPanel.
"3) If the name of your panel is CAL_PANEL then I would assume that your table should be called something like CAL_PANEL_TABLE... Or did you modify the include file yourself?"
TABLE is on a tab called READY_TAB so I assume the table name is READY_TAB_TABLE. The compiler takes that name but complains about CAL_PANEL_TABLE.
"4) What is the cell type of the table you want to read?"
The cell type is numeric.
I think I'll try moving the table off the tab and onto the panel directly. If you have any more suggestions, please let me know.
Thanks again!
Randy
06-22-2013 01:42 PM
Thanks, your questions got me on a useful path.
Moving the table from the tab directly onto the panel worked. Now I wonder what the correct constant name to use would be for a table on a tab?
06-22-2013 01:46 PM
Ok, 1,2 and 4 look ok to me, but may be 3 not, so one more thing: if the table is on a tab panel, you should use the tab panel handle, e.g.,
function ( tabpanel_handle, TABPANEL_4_CONTROL_1, ...)
and use GetPanelHandleFromTabPage to obtain the tabpanel_handle...
06-22-2013 02:15 PM
Thanks that did it! A little trial and error showed that I needed to pass the tab id as the panel parameter (first parameter) to GetTableCellVal.
Here's the code that worked:
const int PARENT = 0;
int calPanelId = 0;
calPanelId = LoadPanel(PARENT, "gui_main.uir", CAL_PANEL);
assert(calPanelId);
int status = -1;
int tabIndex = 1; // zero-based so this is the second tab
int tableHandle = 0;
status = GetPanelHandleFromTabPage(calPanelId, READY_TAB_TABLE, tabIndex, &tableHandle);
assert(status == 0);
Point p;
p.x = 1;
p.y = 1;
double val = -1.0;
status = -1;
status = GetTableCellVal(tableHandle, READY_TAB_TABLE, p, &val);
assert(status == 0);