Hi,
You could use the ANSI C function
strtok() as an alternative approach which would go someting like this:
char *ptrtok = 0;
int row = 1, col = 1; // (1-based index for tables)
// repeat the following segment in a loop for each line...
pseudo -> for (each line)
{
if (strlen(string) > 1)
// => if potentially valid line (optional check)
{
ptrtok = strtok(string, ","); // look
for comma delimiter in string and retrieve the first "token" up to this
point (e.g. "212312")
if (ptrtok) // if delimiter was found...
{
SetTableCellVal
(panel_name, PANEL_TABLE_NAME, MakePoint(col++, row), ptrtok); //
insert first token
// search for
remaining delimters -> NULL will be returned when end of
string is reached, hence any number of delimiters may be present...
while ((ptrtok = strtok(NULL, ",")) != NULL)
SetTableCellVal (panel_name, PANEL_TABLE_NAME, MakePoint(col++, row),
ptrtok); // insert subsequent tokens
}
row++; // increment index for next row
col = 1; // reset column index for new row
}
}
This approach allows each row to have any number of filled column
cells. Note that in the above example, the table cell attributes must
be set to accept strings instead of numbers. However, if you want the
cells to contain true numberics, simply use atoi() or atof() to first
convert the retrieved ptrtok segments to intergers/floats, before
subsequent insertion into table cells. You may have to add code that
ensures that you have a sufficient number of rows and columns prior to
insertion.
John.