diff --git a/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas b/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas index 52840795e..16b1eeb3a 100644 --- a/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas +++ b/applications/lazstats/source/forms/analysis/descriptive/crosstabunit.pas @@ -44,21 +44,14 @@ type procedure SelListDblClick(Sender: TObject); procedure VarListDblClick(Sender: TObject); procedure VarListSelectionChange(Sender: TObject; {%H-}User: boolean); + private - { private declarations } FReportFrame: TReportFrame; FAutosized: Boolean; - -// procedure Initialize; -// procedure GetLevels(AReport: TStrings); -// function IndexPosition(x: IntDyneVec): integer; -// Procedure Tabulate; -// procedure BreakDown(AReport: TStrings); procedure Prepare(out AVarList, AColNoSelected: IntDyneVec); procedure UpdateBtnStates; public - { public declarations } procedure Reset; override; end; @@ -110,7 +103,7 @@ type procedure TCrossTabCalculator.BreakDown; label - 1,2,3,4, printgrid; + 2,3,4; var i, j, row, col, bigmax: integer; ptr1, ptr2: Integer; @@ -148,57 +141,57 @@ begin col := 1; row := 1; - 1: - index := IndexPosition(subscript); - outline := 'For cell levels: '; - for i := 1 to no_in_list do - begin - j := FVarList[i-1]; - value := Format('%s:%3d ',[FDataGrid.Cells[j,0], min_value[i-1] + subscript[i-1] - 1]); - outline := outline + value; - end; - sum := sum + freq[index]; - outgrid[row-1,col-1] := freq[index]; - outline := outline + Format(' Frequency: %3d', [freq[index]]); - FReport.Add(outline); + while true do + begin + index := IndexPosition(subscript); + outline := 'For cell levels: '; + for i := 1 to no_in_list do + begin + j := FVarList[i-1]; + value := Format('%s:%3d ',[FDataGrid.Cells[j,0], min_value[i-1] + subscript[i-1] - 1]); + outline := outline + value; + end; + sum := sum + freq[index]; + outgrid[row-1,col-1] := freq[index]; + outline := outline + Format(' Frequency: %3d', [freq[index]]); + FReport.Add(outline); - subscript[ptr2-1] := subscript[ptr2-1] + 1; - col := col + 1; - if subscript[ptr2-1] <= levels[ptr2-1] then - goto 1; + subscript[ptr2-1] := subscript[ptr2-1] + 1; + col := col + 1; + if subscript[ptr2-1] <= levels[ptr2-1] then + continue; - FReport.Add('Sum across levels: %3d', [sum]); - FReport.Add(''); + FReport.Add('Sum across levels: %3d', [sum]); + FReport.Add(''); - grandsum := grandsum + sum; - sum := 0; - row := row + 1; + grandsum := grandsum + sum; + sum := 0; + row := row + 1; 2: - if ptr1 < 1 then - goto printgrid; + if ptr1 < 1 then + break; - subscript[ptr1-1] := subscript[ptr1-1] + 1; - if subscript[ptr1-1] <= levels[ptr1-1] then - goto 4; + subscript[ptr1-1] := subscript[ptr1-1] + 1; + if subscript[ptr1-1] <= levels[ptr1-1] then + goto 4; 3: - ptr1 := ptr1 - 1; - if ptr1 < 1 then - goto printgrid; - if subscript[ptr1-1] >= levels[ptr1-1] then - goto 3; - subscript[ptr1-1] := subscript[ptr1-1] + 1; + ptr1 := ptr1 - 1; + if ptr1 < 1 then + break; + if subscript[ptr1-1] >= levels[ptr1-1] then + goto 3; + subscript[ptr1-1] := subscript[ptr1-1] + 1; 4: - for i := ptr1 + 1 to no_in_list do - subscript[i-1] := 1; - ptr1 := no_in_list - 1; - col := 1; + for i := ptr1 + 1 to no_in_list do + subscript[i-1] := 1; + ptr1 := no_in_list - 1; + col := 1; - goto 1; + end; -printgrid: title := 'CELL FREQUENCIES BY LEVELS'; for i := 1 to row - 1 do begin