unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, nrclasses, nrcomm, nrcommbox, nrdataproc, nrftbase,
  nrkermit, nrlogfile, ComCtrls, XPMan;
                                     
type
  TForm1 = class(TForm)
    nrKermit1: TnrKermit;
    nrDeviceBox1: TnrDeviceBox;
    nrComm1: TnrComm;
    Memo1: TMemo;
    CheckBox1: TCheckBox;                                   
    eFiles: TEdit;
    Button1: TButton;
    Button2: TButton;
    nrLogFile1: TnrLogFile;
    Memo2: TMemo;
    Button3: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;                                  
    ProgressBar1: TProgressBar;
    Label6: TLabel;
    Button6: TButton;
    Button7: TButton;
    XPManifest1: TXPManifest;
    procedure Button2Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure nrKermit1FileStart(Sender: TObject);
    procedure nrKermit1ChangeState(Sender: TObject);
    procedure nrKermit1FileEnd(Sender: TObject);
    procedure nrKermit1Error(Sender: TObject);
    procedure nrKermit1FatalError(Sender: TObject; ErrorCode,
      Detail: Cardinal; ErrorMsg: String; var RaiseException: Boolean);
    procedure nrKermit1Progress(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }                           
  public
    { Public declarations }       
  end;

var
  Form1: TForm1;

implementation      

{$R *.dfm}                                      

procedure TForm1.Button2Click(Sender: TObject);
begin
  nrComm1.ConfigDialog();
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  try
    nrComm1.Active := CheckBox1.Checked;
  except
    CheckBox1.Checked := nrComm1.Active;
    raise;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
//  nrComm1.SendString('kermit -ir'#13);
//  sleep(300);
  nrKermit1.Send(eFiles.Text);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  nrKermit1.Abort;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin                                
  nrKermit1.SkipFile(False, False);
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
  nrKermit1.SkipFile(True, False);
end;

procedure TForm1.nrKermit1ChangeState(Sender: TObject);
var s:string;
begin
  case TnrKermit(Sender).State of
    fsSend : s := 'Send';
    fsReceive : s := 'Receive';
    else s := 'Listen';              
  end;
  Label3.Caption := s;
end;
                                
procedure TForm1.nrKermit1FileStart(Sender: TObject);
begin
  Label4.Caption := TnrKermit(Sender).FileName + '...';
  Memo2.Lines.Add(Label4.Caption);
end;

procedure TForm1.nrKermit1FileEnd(Sender: TObject);
begin                                                          
  Label4.Caption := TnrKermit(Sender).FileName + ' done.';    
  Memo2.Lines.Add(Label4.Caption);
end;

procedure TForm1.nrKermit1Error(Sender: TObject);
begin
  Label5.Caption := ' Errors ' + IntToStr(TnrKermit(Sender).Errors) +
                    ' from ' + IntToStr(TnrKermit(Sender).ErrorLimit);
end;

procedure TForm1.nrKermit1FatalError(Sender: TObject; ErrorCode,
  Detail: Cardinal; ErrorMsg: String; var RaiseException: Boolean);
begin
  ShowMessage(ErrorMsg);                             
  RaiseException := False;
end;

procedure TForm1.nrKermit1Progress(Sender: TObject);
begin
  Label6.Caption := IntToStr(nrKermit1.FilePosition) + ' / ' +
  IntToStr(nrKermit1.TotalSize); 
end;

end.
