Files

80 lines
1.5 KiB
ObjectPascal

unit ProbZUnit;
{$mode objfpc}{$H+}
{$WARN 6058 off : Call to subroutine "$1" marked as inline is not inlined}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls;
type
{ TProbzForm }
TProbzForm = class(TForm)
Bevel1: TBevel;
Panel1: TPanel;
ReturnBtn: TButton;
CancelBtn: TButton;
ResetBtn: TButton;
ComputeBtn: TButton;
ProbzEdit: TEdit;
Label2: TLabel;
zEdit: TEdit;
Label1: TLabel;
procedure ComputeBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure ResetBtnClick(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
ProbzForm: TProbzForm;
implementation
{$R *.lfm}
uses
Math, MathUnit, Utils;
{ TProbzForm }
procedure TProbzForm.ResetBtnClick(Sender: TObject);
begin
zEdit.Text := '';
ProbzEdit.Text := '';
end;
procedure TProbzForm.ComputeBtnClick(Sender: TObject);
var
zprob, z: double;
begin
if not MyTryStrToFloat(zEdit.Text, z) then
begin
zEdit.SetFocus;
ErrorMsg('No valid number.');
exit;
end;
zProb := 1.0 - NormalDist(z);
ProbzEdit.Text := Format('%6.4f', [zProb]);
end;
procedure TProbzForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
w := MaxValue([CancelBtn.Width, ResetBtn.Width, ComputeBtn.Width, ReturnBtn.Width]);
CancelBtn.Constraints.MinWidth := w;
ResetBtn.Constraints.MinWidth := w;
ComputeBtn.Constraints.MinWidth := w;
ReturnBtn.Constraints.MinWidth := w;
end;
end.