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>
<Filename Value="forms\analysis\cross-classification\twowayloglinunit.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="TwoWayLogLinFrm"/>
<ComponentName Value="TwoWayLogLinForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="TwoWayLogLinUnit"/>

View File

@ -80,7 +80,7 @@ inherited ABCLogLinearForm: TABCLogLinearForm
Height = 290
Top = 67
Width = 376
PageIndex = 0
PageIndex = 1
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 16
TabOrder = 1
@ -429,15 +429,16 @@ inherited ABCLogLinearForm: TABCLogLinearForm
AnchorSideBottom.Control = Page2
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 253
Height = 259
Top = 31
Width = 376
Anchors = [akTop, akLeft, akRight, akBottom]
AutoAdvance = aaDown
BorderSpacing.Top = 8
ColCount = 4
FixedCols = 3
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
TabOrder = 3
end

View File

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

View File

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