Fix some missing validation in ABClogLinUnit.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7918 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-12-03 15:36:09 +00:00
parent ed98904144
commit aecaad587f
4 changed files with 80 additions and 34 deletions

View File

@ -606,7 +606,7 @@
<Unit62> <Unit62>
<Filename Value="forms\analysis\cross-classification\twowayloglinunit.pas"/> <Filename Value="forms\analysis\cross-classification\twowayloglinunit.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="TwoWayLogLinFrm"/> <ComponentName Value="TwoWayLogLinForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TwoWayLogLinUnit"/> <UnitName Value="TwoWayLogLinUnit"/>

View File

@ -80,7 +80,7 @@ inherited ABCLogLinearForm: TABCLogLinearForm
Height = 290 Height = 290
Top = 67 Top = 67
Width = 376 Width = 376
PageIndex = 0 PageIndex = 1
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 16 BorderSpacing.Top = 16
TabOrder = 1 TabOrder = 1
@ -429,15 +429,16 @@ inherited ABCLogLinearForm: TABCLogLinearForm
AnchorSideBottom.Control = Page2 AnchorSideBottom.Control = Page2
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 253 Height = 259
Top = 31 Top = 31
Width = 376 Width = 376
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
AutoAdvance = aaDown
BorderSpacing.Top = 8 BorderSpacing.Top = 8
ColCount = 4 ColCount = 4
FixedCols = 3 FixedCols = 3
MouseWheelOption = mwGrid MouseWheelOption = mwGrid
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goTabs, goThumbTracking, goSmoothScroll] Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goDrawFocusSelected, goEditing, goTabs, goThumbTracking, goSmoothScroll]
RowCount = 2 RowCount = 2
TabOrder = 3 TabOrder = 3
end end

View File

@ -103,7 +103,11 @@ implementation
uses uses
Math, Math,
GridProcs; Utils, GridProcs;
const
INVALID_INT_ERROR = 'Valid positive integer required.';
{ TABCLogLinearForm } { TABCLogLinearForm }
@ -154,42 +158,82 @@ begin
end; end;
procedure TABCLogLinearForm.NColsEditKeyPress(Sender: TObject; var Key: char); procedure TABCLogLinearForm.NColsEditKeyPress(Sender: TObject; var Key: char);
var
n: Integer;
begin begin
if ord(Key) = 13 then NslicesEdit.SetFocus; if ord(Key) = 13 then
begin
if not TryStrToInt(NColsEdit.Text, n) then
begin
ErrorMsg(INVALID_INT_ERROR);
NColsEdit.SetFocus;
exit;
end;
NslicesEdit.SetFocus;
end;
end; end;
procedure TABCLogLinearForm.NRowsEditKeyPress(Sender: TObject; var Key: char); procedure TABCLogLinearForm.NRowsEditKeyPress(Sender: TObject; var Key: char);
var
n: Integer;
begin begin
if ord(Key) = 13 then NcolsEdit.SetFocus; if ord(Key) = 13 then
begin
if not TryStrToInt(NRowsEdit.Text, n) then
begin
ErrorMsg(INVALID_INT_ERROR);
NRowsEdit.SetFocus;
exit;
end;
NcolsEdit.SetFocus;
end;
end; end;
procedure TABCLogLinearForm.NslicesEditKeyPress(Sender: TObject; var Key: char); procedure TABCLogLinearForm.NslicesEditKeyPress(Sender: TObject; var Key: char);
var var
i, j, k, row : integer; i, j, k, row: integer;
Nslices, Ncols, Nrows : integer; nSlices, nCols, nRows: integer;
begin begin
if ord(Key) = 13 then if ord(Key) = 13 then
begin begin
Nrows := StrToInt(NrowsEdit.Text); if not TryStrToInt(NRowsEdit.Text, nRows) then
Ncols := StrToInt(NcolsEdit.Text); begin
Nslices := StrToInt(NslicesEdit.Text); ErrorMsg(INVALID_INT_ERROR);
Grid.RowCount := Nrows * Ncols * Nslices + 1; NRowsEdit.SetFocus;
row := 1; exit;
for k := 1 to Nslices do end;
begin if not TryStrToInt(NColsEdit.Text, nCols) then
for j := 1 to Ncols do begin
begin ErrorMsg(INVALID_INT_ERROR);
for i := 1 to Nrows do NColsEdit.SetFocus;
begin exit;
Grid.Cells[0,row] := IntToStr(i); end;
Grid.Cells[1,row] := IntToStr(j); if not TryStrToInt(NSlicesEdit.Text, nSlices) then
Grid.Cells[2,row] := IntToStr(k); begin
row := row + 1; ErrorMsg(INVALID_INT_ERROR);
end; NSlicesEdit.SetFocus;
end; exit;
end; end;
Grid.SetFocus; Grid.RowCount := nRows * nCols * nSlices + 1;
end;
row := 1;
for k := 1 to nSlices do
begin
for j := 1 to nCols do
begin
for i := 1 to nRows do
begin
Grid.Cells[0,row] := IntToStr(i);
Grid.Cells[1,row] := IntToStr(j);
Grid.Cells[2,row] := IntToStr(k);
row := row + 1;
end;
end;
end;
Grid.SetFocus;
end;
end; end;
procedure TABCLogLinearForm.ColInBtnClick(Sender: TObject); procedure TABCLogLinearForm.ColInBtnClick(Sender: TObject);
@ -623,7 +667,7 @@ begin
PrintTable(Nrows,Ncols,Nslices,LogData,LogRowMarg,LogColMarg,LogSliceMarg,AReport); PrintTable(Nrows,Ncols,Nslices,LogData,LogRowMarg,LogColMarg,LogSliceMarg,AReport);
AReport.Add(''); AReport.Add('');
AReport.Add('======================================================================'); AReport.Add(DIVIDER_AUTO);
AReport.Add(''); AReport.Add('');
astr := 'Cell Parameters'; astr := 'Cell Parameters';
@ -647,7 +691,7 @@ begin
AReport.Add(astr); AReport.Add(astr);
AReport.Add(''); AReport.Add('');
AReport.Add('======================================================================'); AReport.Add(DIVIDER_AUTO);
AReport.Add(''); AReport.Add('');
CellLambdas := nil; CellLambdas := nil;
@ -862,6 +906,7 @@ begin
inherited; inherited;
Grid.ColCount := 4; Grid.ColCount := 4;
Grid.FixedCols := 3;
Grid.RowCount := 2; Grid.RowCount := 2;
Grid.Cells[0,0] := 'ROW'; Grid.Cells[0,0] := 'ROW';
Grid.Cells[1,0] := 'COL'; Grid.Cells[1,0] := 'COL';

View File

@ -10,7 +10,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Printers, ComCtrls, Buttons, StdCtrls, ExtCtrls, Printers, ComCtrls, Buttons,
MainUnit, Globals, DataProcs, ReportFrameUnit, ChartFrameUnit, MainUnit, Globals, ReportFrameUnit, ChartFrameUnit,
BasicStatsReportAndChartFormUnit; BasicStatsReportAndChartFormUnit;