LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetTableCellValue "The control is not the type expected by the function".

Solved!
Go to solution

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

0 Kudos
Message 1 of 7
(5,976 Views)

Sorry, should say GetTableCellVal not Value.

0 Kudos
Message 2 of 7
(5,974 Views)

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?

 

0 Kudos
Message 3 of 7
(5,963 Views)

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

0 Kudos
Message 4 of 7
(5,953 Views)

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?

0 Kudos
Message 5 of 7
(5,950 Views)
Solution
Accepted by randyo

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...

Message 6 of 7
(5,949 Views)

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);

0 Kudos
Message 7 of 7
(5,939 Views)