You've already forked lazarus-ccr
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8048 8e941d3f-bd1b-0410-a28a-d453659cc2b4
103 lines
1.9 KiB
ObjectPascal
103 lines
1.9 KiB
ObjectPascal
unit FProbUnit;
|
|
|
|
{$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
|
|
|
|
{ TFForm }
|
|
|
|
TFForm = class(TForm)
|
|
Bevel1: TBevel;
|
|
CancelBtn: TButton;
|
|
ComputeBtn: TButton;
|
|
DF1Edit: TEdit;
|
|
DF2Edit: TEdit;
|
|
Panel1: TPanel;
|
|
ProbEdit: TEdit;
|
|
FEdit: TEdit;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
Label3: TLabel;
|
|
Label4: TLabel;
|
|
ResetBtn: TButton;
|
|
ReturnBtn: TButton;
|
|
procedure ComputeBtnClick(Sender: TObject);
|
|
procedure FormActivate(Sender: TObject);
|
|
procedure ResetBtnClick(Sender: TObject);
|
|
private
|
|
{ private declarations }
|
|
public
|
|
{ public declarations }
|
|
end;
|
|
|
|
var
|
|
FForm: TFForm;
|
|
|
|
implementation
|
|
|
|
{$R *.lfm}
|
|
|
|
uses
|
|
Math, MathUnit, Utils;
|
|
|
|
{ TFForm }
|
|
|
|
procedure TFForm.ResetBtnClick(Sender: TObject);
|
|
begin
|
|
FEdit.Text := '';
|
|
DF1Edit.Text := '';
|
|
DF2Edit.Text := '';
|
|
ProbEdit.Text := '';
|
|
end;
|
|
|
|
procedure TFForm.ComputeBtnClick(Sender: TObject);
|
|
var
|
|
F, prob: Double;
|
|
df1, df2: Integer;
|
|
begin
|
|
if not MyTryStrToFloat(FEdit.Text, F) then
|
|
begin
|
|
FEdit.SetFocus;
|
|
ErrorMsg('No valid number.');
|
|
exit;
|
|
end;
|
|
|
|
if not TryStrToInt(DF1Edit.Text, df1) then
|
|
begin
|
|
DF1Edit.SetFocus;
|
|
ErrorMsg('No valid integer (must be positive).');
|
|
exit;
|
|
end;
|
|
|
|
if not TryStrToInt(DF2Edit.Text, df2) then
|
|
begin
|
|
DF2Edit.SetFocus;
|
|
ErrorMsg('No valid integer (must be positive).');
|
|
exit;
|
|
end;
|
|
|
|
prob := ProbF(F, df1, df2);
|
|
ProbEdit.Text := Format('%6.4f', [prob]);
|
|
end;
|
|
|
|
procedure TFForm.FormActivate(Sender: TObject);
|
|
var
|
|
w: Integer;
|
|
begin
|
|
w := MaxValue([CancelBtn.Width, ResetBtn.Width, ReturnBtn.Width, ComputeBtn.Width]);
|
|
CancelBtn.Constraints.MinWidth := w;
|
|
ResetBtn.Constraints.MinWidth := w;
|
|
ComputeBtn.Constraints.MinWidth := w;
|
|
ReturnBtn.Constraints.MinWidth := w;
|
|
end;
|
|
|
|
|
|
end.
|
|
|