LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SetTableCellRangeVals

Hi,

I'm running CVI 7.1 and have a question regarding the table control.

Since there are a lot of data we're trying to use the SetTableCellRangeVals function. I've done a lab with float numbers together with SetTableCellRangeVals and that works fine. Now I try to do the same with strings. I have changed the data type of the cells to string. I'm a little bit confused over the format of the string array. How should it be defined? With my code (see below) I can only update one cell. If I try to update several cells I get run-time error (argument too small). Can you help me with the correct definition of my data buffer?

Regards
Jonas Begström
Teleca Sweden West
jonas.bergstrom@sys.teleca.se
+46 703 79 11 81


char buffer[10][10][10];
char *pBuffer;

pBuffer = buffer[0][0];

// columns defined in uir file
InsertTableRows (mPhoneBook.pbPanelHandle, mPhoneBook.pbControlHandler, cntRow, 1000, VAL_CELL_STRING);

.
.
. buffer is filled with data ...
.
.


// this works fine
SetTableCellRangeVals(mPhoneBook.pbPanelHandle, mPhoneBook.pbControlHandler,
MakeRect (2, 2, 1, 1), &pBuffer, VAL_ROW_MAJOR);

// run time error
SetTableCellRangeVals(mPhoneBook.pbPanelHandle, mPhoneBook.pbControlHandler,
MakeRect (2, 2, 2, 2), &pBuffer, VAL_ROW_MAJOR);
0 Kudos
Message 1 of 2
(3,242 Views)
Hello, Jonas

If you're using SetTableCellRangeVals to set strings, the function expects that you pass it an array of strings (i.e. an array of arrays). In your code, pBuffer is an array of 10 characters. By passing the address of that variable, you get the data type right, but you are only passing a single string (in C, a pointer is equivalent to an array of one element).

You will need to change the way your buffer data is stored. It should be something like this:

char *buffer[10][10];

This data type will hold one string for each cell in the 10x10 range. You will have to allocate each string individually, however, and then free it when you no longer need it.

Luis
NI
Message 2 of 2
(3,237 Views)