Unit ProgramForm;

Interface

Uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, StdCtrls, Buttons;

Type
  TfrmProgram = Class(TForm)
    EditFStart: TEdit;
    EditFEnd: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    EditTotalDuration: TEdit;
    MemoLevels: TMemo;
    Label4: TLabel;
    EditNSteps: TEdit;
    Label5: TLabel;
    BitBtnOK: TBitBtn;
    BitBtnCancel: TBitBtn;
    Procedure FormKeyDown(Sender: TObject; Var Key: Word;
      Shift: TShiftState);
    Procedure FormShow(Sender: TObject);
    Procedure BitBtnOKClick(Sender: TObject);
    Procedure EditTotalDurationChange(Sender: TObject);
    Procedure EditNStepsChange(Sender: TObject);
    Procedure EditFStartChange(Sender: TObject);
    Procedure EditFEndChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    TotalDuration: integer;
    FrequencySteps: integer;
    StartFrequency: integer;
    EndFrequency: integer;
    LevelList: String;
  End;

Var
  frmProgram: TfrmProgram;

Implementation

{$R *.DFM}

Procedure TfrmProgram.FormKeyDown(Sender: TObject; Var Key: Word;
  Shift: TShiftState);
Begin
  Case Key Of
    VK_F5: BitBtnOK.Click;
  End;
End;

(*
function TFormProgram.GetLevels: string;
var
  sl: TStringList;
  i: integer;
begin
  sl := TStringList.Create;
  for i := 0 to MemoLevels.Lines.Count-1 do
    sl.Add (MemoLevels.Lines [i]);
  Result := sl.CommaText;
  sl.Free;
end;
*)

Procedure TfrmProgram.FormShow(Sender: TObject);
Var
  sl: TStringList;
Begin
  EditTotalDuration.Text := IntToStr(TotalDuration);
  EditNSteps.Text := IntToStr(FrequencySteps);
  EditFStart.Text := IntToStr(StartFrequency);
  EditFEnd.Text := IntToStr(EndFrequency);
  sl := TStringList.Create;
  sl.CommaText := LevelList;
  ;
  MemoLevels.Lines := sl;
  sl.Free;
End;

Procedure TfrmProgram.BitBtnOKClick(Sender: TObject);
Begin
  Inherited Click;
End;

Procedure TfrmProgram.EditTotalDurationChange(Sender: TObject);
Begin
  Try
    TotalDuration := StrToInt(EditTotalDuration.Text);
  Except
    ShowMessage('Bad value for duration - must be an integer');
    EditTotalDuration.Text := IntToStr(TotalDuration);
  End;
End;

Procedure TfrmProgram.EditNStepsChange(Sender: TObject);
Begin
  Try
    FrequencySteps := StrToInt(EditNSteps.Text);
  Except
    ShowMessage('Bad value for number of steps - must be an integer');
    EditNSteps.Text := IntToStr(FrequencySteps);
  End;
End;

Procedure TfrmProgram.EditFStartChange(Sender: TObject);
Begin
  Try
    StartFrequency := StrToInt(EditFStart.Text);
  Except
    ShowMessage('Bad value for start frequency - must be an integer');
    EditFStart.Text := IntToStr(StartFrequency);
  End;
End;

Procedure TfrmProgram.EditFEndChange(Sender: TObject);
Begin
  Try
    EndFrequency := StrToInt(EditFEnd.Text);
  Except
    ShowMessage('Bad value for end frequency - must be an integer');
    EditFEnd.Text := IntToStr(EndFrequency);
  End;
End;

End.
