LazStats: Inherited SignTestUnit from TBasicStatsReportForm.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7810 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-10-26 14:32:48 +00:00
parent eb11d1eda2
commit ded71d0f59
2 changed files with 387 additions and 433 deletions

View File

@ -1,236 +1,181 @@
object SignTestFrm: TSignTestFrm inherited SignTestFrm: TSignTestFrm
Left = 550 Left = 550
Height = 372 Height = 345
Top = 297 Top = 297
Width = 391 Width = 382
AutoSize = True
Caption = 'The Matched Pairs Sign Test' Caption = 'The Matched Pairs Sign Test'
ClientHeight = 372 ClientHeight = 345
ClientWidth = 391 ClientWidth = 382
OnActivate = FormActivate inherited ParamsPanel: TPanel
OnCreate = FormCreate Height = 329
OnShow = FormShow ClientHeight = 329
LCLVersion = '2.1.0.0' inherited CloseBtn: TButton
object Label1: TLabel Top = 304
AnchorSideLeft.Control = Owner end
AnchorSideTop.Control = Owner inherited ComputeBtn: TButton
Left = 8 Top = 304
Height = 15 end
Top = 8 inherited ResetBtn: TButton
Width = 97 Top = 304
BorderSpacing.Left = 8 end
BorderSpacing.Top = 8 inherited HelpBtn: TButton
Caption = 'Variables Available' Top = 304
ParentColor = False end
inherited ButtonBevel: TBevel
Top = 288
end
object Label1: TLabel[5]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = ParamsPanel
Left = 0
Height = 15
Top = 0
Width = 100
Caption = 'Available Variables:'
ParentColor = False
end
object Label2: TLabel[6]
AnchorSideLeft.Control = Var1Edit
AnchorSideBottom.Control = Var1Edit
Left = 166
Height = 15
Top = 21
Width = 50
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable 1'
ParentColor = False
end
object Label3: TLabel[7]
AnchorSideLeft.Control = Var2Edit
AnchorSideBottom.Control = Var2Edit
Left = 166
Height = 15
Top = 109
Width = 50
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable 2'
ParentColor = False
end
object VarList: TListBox[8]
AnchorSideLeft.Control = ParamsPanel
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Var1In
AnchorSideBottom.Control = ButtonBevel
Left = 0
Height = 271
Top = 17
Width = 126
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 2
BorderSpacing.Right = 6
ItemHeight = 0
OnDblClick = VarListDblClick
OnSelectionChange = VarListSelectionChange
TabOrder = 4
end
object Var1In: TBitBtn[9]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 132
Height = 26
Top = 17
Width = 26
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var1InClick
Spacing = 0
TabOrder = 5
end
object Var1Out: TBitBtn[10]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1In
AnchorSideTop.Side = asrBottom
Left = 132
Height = 26
Top = 47
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var1OutClick
Spacing = 0
TabOrder = 6
end
object Var2In: TBitBtn[11]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1Out
AnchorSideTop.Side = asrBottom
Left = 132
Height = 26
Top = 105
Width = 26
BorderSpacing.Top = 32
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var2InClick
Spacing = 0
TabOrder = 7
end
object Var2Out: TBitBtn[12]
AnchorSideLeft.Control = ParamsPanel
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var2In
AnchorSideTop.Side = asrBottom
Left = 132
Height = 26
Top = 135
Width = 26
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var2OutClick
Spacing = 0
TabOrder = 8
end
object Var1Edit: TEdit[13]
AnchorSideLeft.Control = Var1In
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var1Out
AnchorSideBottom.Side = asrBottom
Left = 166
Height = 23
Top = 38
Width = 125
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 9
Text = 'Var1Edit'
end
object Var2Edit: TEdit[14]
AnchorSideLeft.Control = Var2In
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = ParamsPanel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var2Out
AnchorSideBottom.Side = asrBottom
Left = 166
Height = 23
Top = 126
Width = 125
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 10
Text = 'Var2Edit'
end
end end
object Label2: TLabel inherited ParamsSplitter: TSplitter
AnchorSideLeft.Control = Var1Edit Height = 345
AnchorSideBottom.Control = Var1Edit
Left = 217
Height = 15
Top = 33
Width = 50
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable 1'
ParentColor = False
end
object Label3: TLabel
AnchorSideLeft.Control = Var2Edit
AnchorSideBottom.Control = Var2Edit
Left = 217
Height = 15
Top = 125
Width = 50
Anchors = [akLeft, akBottom]
BorderSpacing.Bottom = 2
Caption = 'Variable 2'
ParentColor = False
end
object VarList: TListBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Var1In
AnchorSideBottom.Control = Bevel1
Left = 8
Height = 298
Top = 25
Width = 165
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
Constraints.MinHeight = 200
ItemHeight = 0
OnSelectionChange = VarListSelectionChange
TabOrder = 0
end
object Var1In: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = VarList
Left = 181
Height = 28
Top = 25
Width = 28
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var1InClick
Spacing = 0
TabOrder = 1
end
object Var1Out: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1In
AnchorSideTop.Side = asrBottom
Left = 181
Height = 28
Top = 57
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var1OutClick
Spacing = 0
TabOrder = 2
end
object Var2In: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var1Out
AnchorSideTop.Side = asrBottom
Left = 181
Height = 28
Top = 117
Width = 28
BorderSpacing.Top = 32
Images = MainDataModule.ImageList
ImageIndex = 1
OnClick = Var2InClick
Spacing = 0
TabOrder = 4
end
object Var2Out: TBitBtn
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = Var2In
AnchorSideTop.Side = asrBottom
Left = 181
Height = 28
Top = 149
Width = 28
BorderSpacing.Top = 4
Images = MainDataModule.ImageList
ImageIndex = 0
OnClick = Var2OutClick
Spacing = 0
TabOrder = 5
end
object Var1Edit: TEdit
AnchorSideLeft.Control = Var1In
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var1Out
AnchorSideBottom.Side = asrBottom
Left = 217
Height = 23
Top = 50
Width = 166
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 3
Text = 'Var1Edit'
end
object Var2Edit: TEdit
AnchorSideLeft.Control = Var2In
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Var2Out
AnchorSideBottom.Side = asrBottom
Left = 217
Height = 23
Top = 142
Width = 166
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 12
ReadOnly = True
TabOrder = 6
Text = 'Var2Edit'
end
object ResetBtn: TButton
AnchorSideRight.Control = ComputeBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 182
Height = 25
Top = 339
Width = 54
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Reset'
OnClick = ResetBtnClick
TabOrder = 7
end
object ComputeBtn: TButton
AnchorSideRight.Control = CloseBtn
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 244
Height = 25
Top = 339
Width = 76
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Compute'
OnClick = ComputeBtnClick
TabOrder = 8
end
object CloseBtn: TButton
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 328
Height = 25
Top = 339
Width = 55
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Left = 8
BorderSpacing.Top = 8
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Close'
ModalResult = 11
TabOrder = 9
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CloseBtn
Left = 0
Height = 8
Top = 323
Width = 391
Anchors = [akLeft, akRight, akBottom]
Shape = bsBottomLine
end end
end end

View File

@ -5,19 +5,14 @@ unit SignTestUnit;
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons, ExtCtrls,
StdCtrls, Buttons, ExtCtrls, MainUnit, FunctionsLib, Globals, BasicStatsReportFormUnit;
MainUnit, OutputUnit, FunctionsLib, Globals, DataProcs;
type type
{ TSignTestFrm } { TSignTestFrm }
TSignTestFrm = class(TForm) TSignTestFrm = class(TBasicStatsReportForm)
Bevel1: TBevel;
ResetBtn: TButton;
ComputeBtn: TButton;
CloseBtn: TButton;
Var1In: TBitBtn; Var1In: TBitBtn;
Var1Out: TBitBtn; Var1Out: TBitBtn;
Var2In: TBitBtn; Var2In: TBitBtn;
@ -28,22 +23,22 @@ type
Label2: TLabel; Label2: TLabel;
Label3: TLabel; Label3: TLabel;
VarList: TListBox; VarList: TListBox;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
procedure Var1InClick(Sender: TObject); procedure Var1InClick(Sender: TObject);
procedure Var1OutClick(Sender: TObject); procedure Var1OutClick(Sender: TObject);
procedure Var2InClick(Sender: TObject); procedure Var2InClick(Sender: TObject);
procedure Var2OutClick(Sender: TObject); procedure Var2OutClick(Sender: TObject);
procedure VarListDblClick(Sender: TObject);
procedure VarListSelectionChange(Sender: TObject; User: boolean); procedure VarListSelectionChange(Sender: TObject; User: boolean);
private private
{ private declarations }
FAutoSized: Boolean; protected
procedure UpdateBtnStates; procedure AdjustConstraints; override;
procedure Compute; override;
procedure UpdateBtnStates; override;
function Validate(out AMsg: String; out AControl: TWinControl): boolean; override;
public public
{ public declarations } procedure Reset; override;
end; end;
var var
@ -51,200 +46,105 @@ var
implementation implementation
{$R *.lfm}
uses uses
Math; Math,
GridProcs;
{ TSignTestFrm } { TSignTestFrm }
procedure TSignTestFrm.ResetBtnClick(Sender: TObject); procedure TSignTestFrm.AdjustConstraints;
var
i: integer;
begin begin
Var1Edit.Text := ''; inherited;
Var2Edit.Text := '';
VarList.Items.Clear; ParamsPanel.Constraints.MinWidth := 4*CloseBtn.Width + 3*CloseBtn.BorderSpacing.Left;
for i := 1 to NoVariables do ParamsPanel.Constraints.MinHeight := Var2Out.Top + Var2Out.Height +
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]); ButtonBevel.Height + CloseBtn.Height + CloseBtn.Borderspacing.Top;
UpdateBtnStates;
end; end;
procedure TSignTestFrm.Var1InClick(Sender: TObject);
procedure TSignTestFrm.Compute;
var var
index: integer; ColNoSelected: IntDyneVec = nil;
DifSigns: IntDyneVec = nil;
i, col1, col2, X, N, A, b, Temp: integer;
p, Q, Probability, z, NoDiff, CorrectedA, x1, x2: double;
SumProb: double;
lReport: TStrings;
begin begin
index := VarList.ItemIndex; SumProb := 0.0;
if (index > -1) and (Var1Edit.Text = '') then SetLength(DifSigns, NoCases);
// Get column numbers and labels of variables selected
SetLength(ColNoSelected, 2);
ColNoSelected[0] := GetVariableIndex(OS3MainFrm.DataGrid, Var1Edit.Text);
ColNoSelected[1] := GetVariableIndex(OS3MainFrm.DataGrid, Var2Edit.Text);
p := 0.5;
Q := 0.5;
// Get sign of difference between pairs '(-1 := - ; 0 := no difference; +1 := +
A := 0;
b := 0;
NoDiff := 0.0;
for i := 1 to NoCases do
begin begin
Var1Edit.Text := VarList.Items[index]; if (not GoodRecord(OS3MainFrm.DataGrid, i, ColNoSelected)) then continue;
VarList.Items.Delete(index); col1 := ColNoSelected[0];
end; col2 := ColNoSelected[1];
UpdateBtnStates; x1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[col1, i]));
end; x2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[col2, i]));
if (x1 > x2) then
procedure TSignTestFrm.Var1OutClick(Sender: TObject);
begin
if Var1Edit.Text <> '' then
begin
VarList.Items.Add(Var1Edit.Text);
Var1Edit.Text := '';
end;
UpdateBtnStates;
end;
procedure TSignTestFrm.Var2InClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var2Edit.Text = '') then
begin
Var2Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TSignTestFrm.Var2OutClick(Sender: TObject);
begin
if Var2Edit.Text <> '' then
begin
VarList.Items.Add(Var2Edit.Text);
Var2Edit.Text := '';
end;
UpdateBtnStates;
end;
procedure TSignTestFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TSignTestFrm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if FAutoSized then
exit;
w := MaxValue([ResetBtn.Width, ComputeBtn.Width, CloseBtn.Width]);
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
CloseBtn.Constraints.MinWidth := w;
Constraints.MinWidth := 4*w; //Width;
Constraints.MinHeight := Height;
FAutoSized := true;
end;
procedure TSignTestFrm.FormCreate(Sender: TObject);
begin
Assert(OS3MainFrm <> nil);
end;
procedure TSignTestFrm.FormShow(Sender: TObject);
begin
ResetBtnClick(self);
end;
procedure TSignTestFrm.ComputeBtnClick(Sender: TObject);
var
i, k, col1, col2, X, N, A, b, Temp : integer;
ColNoSelected : IntDyneVec;
DifSigns : IntDyneVec;
p, Q, Probability, z, NoDiff, CorrectedA, x1, x2 : double;
SumProb : double;
cellstring: string;
lReport: TStrings;
begin
if Var1Edit.Text = '' then
begin
MessageDlg('Variable 1 not selected.', mtError, [mbOK], 0);
exit;
end;
if Var2Edit.Text = '' then
begin
MessageDlg('Variable 2 not selected.', mtError, [mbOK], 0);
exit;
end;
SumProb := 0.0;
SetLength(DifSigns,NoCases);
SetLength(ColNoSelected,NoVariables);
k := 2;
// Get column numbers and labels of variables selected
for i := 1 to NoVariables do
begin begin
cellstring := OS3MainFrm.DataGrid.Cells[i,0]; DifSigns[i-1] := 1;
if cellstring = Var1Edit.Text then ColNoSelected[0] := i; A := A + 1;
if cellstring = Var2Edit.Text then ColNoSelected[1] := i; end;
if (x1 < x2) then
begin
DifSigns[i-1] := -1;
b := b + 1;
end;
if (x1 = x2) then
begin
DifSigns[i-1] := 0;
NoDiff := NoDiff + 1.0;
end;
end;
// Show results
lReport := TStringList.Create;
try
lReport.Add('RESULTS FOR THE SIGN TEST');
lReport.Add('');
lReport.Add('Frequency of %d out of %d observed + sign differences.', [A, NoCases]);
lReport.Add('Frequency of %d out of %d observed - sign differences.', [b, NoCases]);
lReport.Add('Frequency of %.0f out of %d observed no differences.', [NoDiff, NoCases]);
lReport.Add('');
lReport.Add('The theoretical proportion expected for +''s or -''s is 0.5 ');
lReport.Add('The test is for the probability of the +''s or -''s (which ever is fewer)');;
lReport.Add('as small or smaller than that observed given the expected proportion.');
lReport.Add('');
// Swap A and B around if A > B
if (A > b) then
begin
Temp := A;
A := b;
b := Temp;
end; end;
p := 0.5; N := A + b;
Q := 0.5; if (N > 25) then // Use normal distribution approximation
// Get sign of difference between pairs '(-1 := - ; 0 := no difference; +1 := +
A := 0;
b := 0;
NoDiff := 0.0;
for i := 1 to NoCases do
begin begin
if (not GoodRecord(i,k,ColNoSelected)) then continue; CorrectedA := A;
col1 := ColNoSelected[0]; if (A < N * p) then CorrectedA := A + 0.5;
col2 := ColNoSelected[1]; if (A > N * p) then CorrectedA := A - 0.5;
x1 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[col1,i])); z := (CorrectedA - N * p) / sqrt(N * p * Q);
x2 := StrToFloat(Trim(OS3MainFrm.DataGrid.Cells[col2,i])); lReport.Add('Z value for Normal Distribution approximation: %.3f', [z]);
if (x1 > x2) then Probability := ProbZ(z);
begin lReport.Add('Probability: %.4f', [Probability]);
DifSigns[i-1] := 1;
A := A + 1;
end;
if (x1 < x2) then
begin
DifSigns[i-1] := -1;
b := b + 1;
end;
if (x1 = x2) then
begin
DifSigns[i-1] := 0;
NoDiff := NoDiff + 1.0;
end;
end;
// Show results
lReport := TStringList.Create;
try
lReport.Add('RESULTS FOR THE SIGN TEST');
lReport.Add('');
lReport.Add('Frequency of %d out of %d observed + sign differences.', [A, NoCases]);
lReport.Add('Frequency of %d out of %d observed - sign differences.', [b, NoCases]);
lReport.Add('Frequency of %.0f out of %d observed no differences.', [NoDiff, NoCases]);
lReport.Add('');
lReport.Add('The theoretical proportion expected for +''s or -''s is 0.5 ');
lReport.Add('The test is for the probability of the +''s or -''s (which ever is fewer)');;
lReport.Add('as small or smaller than that observed given the expected proportion.');
lReport.Add('');
// Swap A and B around if A > B
if (A > b) then
begin
Temp := A;
A := b;
b := Temp;
end;
N := A + b;
if (N > 25) then // Use normal distribution approximation
begin
CorrectedA := A;
if (A < N * p) then CorrectedA := A + 0.5;
if (A > N * p) then CorrectedA := A - 0.5;
z := (CorrectedA - N * p) / sqrt(N * p * Q);
lReport.Add('Z value for Normal Distribution approximation: %.3f', [z]);
Probability := probz(z);
lReport.Add('Probability: %.4f', [Probability]);
end end
else // Use binomial fomula else // Use binomial fomula
begin begin
@ -259,14 +159,126 @@ begin
lReport.Add('Binomial Probability of %d or smaller out of %d: %.4f', [A, N, SumProb]); lReport.Add('Binomial Probability of %d or smaller out of %d: %.4f', [A, N, SumProb]);
end; end;
DisplayReport(lReport); FReportFrame.DisplayReport(lReport);
finally finally
lReport.Free; lReport.Free;
DifSigns := nil;
ColNoSelected := nil;
end; end;
end; end;
procedure TSignTestFrm.Reset;
var
i: integer;
begin
inherited;
Var1Edit.Clear;
Var2Edit.Clear;
VarList.Items.Clear;
for i := 1 to NoVariables do
VarList.Items.Add(OS3MainFrm.DataGrid.Cells[i,0]);
UpdateBtnStates;
end;
function TSignTestFrm.Validate(out AMsg: String; out AControl: TWinControl): boolean;
begin
Result := false;
if Var1Edit.Text = '' then
begin
AMsg := 'Variable 1 not selected.';
AControl := Var1Edit;
exit;
end;
if Var2Edit.Text = '' then
begin
AMsg := 'Variable 2 not selected.';
AControl := Var2Edit;
exit;
end;
Result := true;
end;
procedure TSignTestFrm.Var1InClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var1Edit.Text = '') then
begin
Var1Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TSignTestFrm.Var1OutClick(Sender: TObject);
begin
if Var1Edit.Text <> '' then
begin
VarList.Items.Add(Var1Edit.Text);
Var1Edit.Text := '';
end;
UpdateBtnStates;
end;
procedure TSignTestFrm.Var2InClick(Sender: TObject);
var
index: integer;
begin
index := VarList.ItemIndex;
if (index > -1) and (Var2Edit.Text = '') then
begin
Var2Edit.Text := VarList.Items[index];
VarList.Items.Delete(index);
end;
UpdateBtnStates;
end;
procedure TSignTestFrm.Var2OutClick(Sender: TObject);
begin
if Var2Edit.Text <> '' then
begin
VarList.Items.Add(Var2Edit.Text);
Var2Edit.Text := '';
end;
UpdateBtnStates;
end;
procedure TSignTestFrm.VarListDblClick(Sender: TObject);
var
index: Integer;
s: String;
begin
index := Varlist.ItemIndex;;
if index > -1 then
begin
s := VarList.Items[index];
if Var1Edit.Text = '' then
Var1Edit.Text := s
else
if Var2Edit.Text = '' then
Var2Edit.Text := s;
Varlist.Items.Delete(index);
UpdateBtnStates;
end;
end;
procedure TSignTestFrm.VarListSelectionChange(Sender: TObject; User: boolean);
begin
UpdateBtnStates;
end;
procedure TSignTestFrm.UpdateBtnStates; procedure TSignTestFrm.UpdateBtnStates;
begin begin
Var1In.Enabled := (VarList.ItemIndex > -1) and (Var1Edit.Text = ''); Var1In.Enabled := (VarList.ItemIndex > -1) and (Var1Edit.Text = '');
@ -276,8 +288,5 @@ begin
end; end;
initialization
{$I signtestunit.lrs}
end. end.