diff --git a/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas b/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas index 5dbe11cd1..6eecee104 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/xvsmultyunit.pas @@ -96,7 +96,7 @@ begin exit; end; - xCol := OS3MainFrm.DataGrid.Rows[0].IndexOf(Trim(XEdit.Text)); + xCol := GetVariableIndex(OS3MainFrm.DataGrid, Trim(XEdit.Text)); if xCol = -1 then begin ErrorMsg('X variable not found.'); @@ -104,14 +104,14 @@ begin end; nY := YBox.Items.Count; - SetLength(selected, nY + 1); // one more for the x column, needed by Correlations() + NoSelected := nY + 1; // one more for the x column, needed by Correlations() + SetLength(selected, NoSelected); for j := 0 to nY - 1 do - selected[j] := OS3MainFrm.DataGrid.Rows[0].IndexOf(YBox.Items[j]); - selected[nY] := xCol; - NoSelected := nY + 1; + selected[j] := GetVariableIndex(OS3MainFrm.DataGrid, YBox.Items[j]); + selected[nY] := xCol; // This goes into the extra element of "selected" - SetLength(RowLabels, NoVariables); - SetLength(ColLabels, NoVariables); + SetLength(RowLabels, NoSelected); + SetLength(ColLabels, NoSelected); for i := 0 to NoSelected-1 do begin RowLabels[i] := Trim(OS3MainFrm.DataGrid.Cells[selected[i],0]);