LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a bug in CVI 2010 in SetTableCellRangeVals and SetTableCellRangeAttribute for strings - particularly in 64 bit mode?

Solved!
Go to solution

It seems that I can only get SetTableCellRangeVals to post string data to a table in 32 bit mode, I can't get SetTableCellRangeAttribute to work for string arrays and now it appears numerics either. I just get garbage - this could be my code though.

 

Worse in 64 bit mode I can't get either to post anything (for strings at least) but get a GP fault instead.

 

I have played with the size of the pointer to the string array (from 4 to 8 bytes

 

The heart of the test code is here but files are attached as well.

 

int CVICALLBACK Test_callback (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 int  i, numrows = 10, byattrib;
 int  bit32 = 1;
 double  *dbl_array;
 char **string_array, *string;
 Rect a_rect;
 
 switch (event)
  {
  case EVENT_COMMIT:
   GetCtrlVal (main_handle, PANEL_BYATTRIB, &byattrib);
   string = malloc (50 * sizeof (char));
   if (bit32)
    string_array = malloc (4 * numrows * sizeof (char));  
   else
    string_array = malloc (8 * numrows * sizeof (char));
   for (i = 0; i < numrows; i++)
    string_array[i] = malloc (50 * sizeof (char));
   dbl_array = malloc (numrows * sizeof (double));
   
   for (i = 0; i < numrows; i++)
    {
    dbl_array[i] = i * i * 3.1416;
    Fmt (string, "The value is %f", dbl_array[i]);
    strcpy (string_array[i], string);
    }
   
   a_rect.top = 1;
   a_rect.left = 1;
   a_rect.height = numrows;
   a_rect.width = 1;
   
   status = DeleteTableRows (main_handle, PANEL_TABLE, 1, -1);
   
   status = InsertTableRows (main_handle, PANEL_TABLE, -1, numrows, VAL_USE_MASTER_CELL_TYPE);
   
   if (byattrib)
    {
    status = SetTableCellRangeAttribute (main_handle, PANEL_TABLE, a_rect, ATTR_CTRL_VAL, dbl_array);
   
    a_rect.left = 2;
    status = SetTableCellRangeAttribute (main_handle, PANEL_TABLE, a_rect, ATTR_CTRL_VAL, string_array);
    }
   
   else
    {
    status = SetTableCellRangeVals (main_handle, PANEL_TABLE, a_rect, dbl_array, VAL_ROW_MAJOR);
   
    a_rect.left = 2;
    status = SetTableCellRangeVals (main_handle, PANEL_TABLE, a_rect, string_array, VAL_ROW_MAJOR);
    }
   
   free (string);
   for (i = 0; i < numrows; i++)
    free (string_array[i]);
   free (string_array);
   free (dbl_array);
   break;
  }
 return 0;
}

 

 

Thanks for any help,

Greg

0 Kudos
Message 1 of 6
(3,158 Views)
Solution
Accepted by topic author blakney

Hey Greg -

 

You've definitely found a bug.  However, I think the issues you're running into for SetTableCellRangeAttribute are the result of a misunderstanding of the function.  That function, when using it to set the value, sets the values of all cells in the range to the same value.  As a result, the var_args parameter should be the value you want to set all the cells to, and not a pointer to an array of values.  In your code, you would need to dereference the arrays, and then you would see that all the cells are set to the same value, which is the expected behaviour.

 

I've created a bug report for the crash that results from setting values on string cell types in 64-bit with ID 284842.  This bug will be fixed in the next maintenace release of CVI.  In the meantime, you should be able to use SetTableCellVal to set the value of each cell individually in 64-bit.

 

I'm sorry for the inconvenience -

 

NickB

National Instruments

0 Kudos
Message 2 of 6
(3,134 Views)

I kind of wondered if the SetTableCellRangeVals acted as a simple fill as opposed my attempted workaround. I'll take the pain and load the panel with SetCtrlVal  in a loop.

 

Thanks for the quick response.

0 Kudos
Message 3 of 6
(3,128 Views)

Greg,

 

For values (but not for attributes) there is a fill function: It's FillTableCellRange.

 

Luis

0 Kudos
Message 4 of 6
(3,114 Views)

It appears that 10.0.1 Fixed this issue.Smiley Tongue Thank you.

 

If I am mistaken please let me know.

0 Kudos
Message 5 of 6
(2,903 Views)

Just FYI -

 

The status of any bug ID given on these forums should be available on the known issues lists.  For instance, if you find bug ID 284842 (given above) on one of the known issues lists, you'll see that it was indeed resolved in CVI 2010 SP1.

 

I'm glad the issue is resolved for you!

 

NickB

National Instruments

0 Kudos
Message 6 of 6
(2,898 Views)