I have a program where the contents of several data sets can be displayed in a table. This usually works absolutely fine, but sometimes a program error occurs. This program error only occurs when the program is in a release configuration in a stand alone directory (installed with a distribution kit). Testing from within LW (either debug or release) works like a charm, copying the exact same exe file over the installed version generates the error when the program is run from there. I re-created the dist kit to ensure the same LW RTE is used, but to no avail.
Since there was no way to test this from within LW I included some printf lines in the code to see where the crash occurs. It seems to happen when the line
SetTableCellAttribute (hPanel, TABLEPANEL_TABLE, p, ATTR_CELL_TYPE, VAL_CELL_STRING);
is executed. Point p is within the range of table cells. Any ideas anyone?
CVI 6, BTW
Below is the full part of the code.
hPanel = LoadPanel (0, "SVPanels.uir", TABLEPANEL);
// define the maximum number of rows. Make it equal to the longest set to display
for (i=0; i < NrOfSets; i++) if (MaxNrOfElements < DS[i].NrOfElements) MaxNrOfElements = DS[i].NrOfElements;
// make the table empty
DeleteTableRows (hPanel, TABLEPANEL_TABLE, 1, -1);
DeleteTableColumns (hPanel, TABLEPANEL_TABLE, 1, -1);
// insert the nr. of rows equal to the longest data set
InsertTableRows (hPanel, TABLEPANEL_TABLE, -1, MaxNrOfElements, VAL_CELL_NUMERIC);
// fill the table with the data sets
for (i=0; i < NrOfSets; i++) {
// insert 2 columns, X and Y
InsertTableColumns (hPanel, TABLEPANEL_TABLE, -1, 2, VAL_CELL_NUMERIC);
NrOfCols += 2;
// Name the columns X1 Y1 X2 Y2 etc..
Fmt(LabelName, "%s<%s%i", "X", i+1);
SetTableColumnAttribute (hPanel, TABLEPANEL_TABLE, NrOfCols - 1, ATTR_USE_LABEL_TEXT, 1);
SetTableColumnAttribute (hPanel, TABLEPANEL_TABLE, NrOfCols - 1, ATTR_LABEL_TEXT, LabelName);
Fmt(LabelName, "%s<%s%i", "Y", i+1);
SetTableColumnAttribute (hPanel, TABLEPANEL_TABLE, NrOfCols, ATTR_USE_LABEL_TEXT, 1);
SetTableColumnAttribute (hPanel, TABLEPANEL_TABLE, NrOfCols, ATTR_LABEL_TEXT, LabelName);
// fill the columns with the data set values:
// DS[i].X is the X float array of data set i, allocated with malloc()
SetTableCellRangeVals (hPanel, TABLEPANEL_TABLE,
MakeRect (1, NrOfCols-1, DS[i].NrOfElements, 1), DS[i].X, VAL_COLUMN_MAJOR);
SetTableCellRangeVals (hPanel, TABLEPANEL_TABLE,
MakeRect (1, NrOfCols, DS[i].NrOfElements, 1), DS[i].Y, VAL_COLUMN_MAJOR);
// if the data set has fewer elements than the longest one,
// make the remaining column cells empty
if (DS[i].NrOfElements < MaxNrOfElements) {
Point p;
for (j=DS[i].NrOfElements + 1; j <= MaxNrOfElements; j++) {
p = MakePoint(NrOfCols-1, j);
printf("%i %i %i %i %i Val zero: ", j, NrOfCols, MaxNrOfElements, p.x, p.y);
SetTableCellAttribute (hPanel, TABLEPANEL_TABLE, p, ATTR_CTRL_VAL, 0);
printf("%i %i %i %i %i Type string: ", j, NrOfCols, MaxNrOfElements, p.x, p.y);
// ******* AT THIS POINT THE PROGRAM CRASHES ********
// ******* THE STRING ABOVE IS PRINTED AND THEN THE PROGRAM ERROR OCCURS ********
SetTableCellAttribute (hPanel, TABLEPANEL_TABLE, p, ATTR_CELL_TYPE, VAL_CELL_STRING);
printf("%i %i %i %i %i Val empty: ", j, NrOfCols, MaxNrOfElements, p.x, p.y);
SetTableCellAttribute (hPanel, TABLEPANEL_TABLE, p, ATTR_CTRL_VAL, "");
p = MakePoint(NrOfCols, j);
SetTableCellAttribute (hPanel, TABLEPANEL_TABLE, p, ATTR_CELL_TYPE, VAL_CELL_STRING);
SetTableCellAttribute (hPanel, TABLEPANEL_TABLE, p, ATTR_CTRL_VAL, "");
} // for (j=...)
} // if (DS[i].NrOfElements < MaxNrOfElements)
} // for (i=0; i
SetWaitCursor(0);
InstallPopup (hPanel);