unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, nrcommbox, nrclasses, nrcomm, ExtCtrls;

type
  TForm1 = class(TForm)
    nrComm1: TnrComm;
    nrDeviceBox1: TnrDeviceBox;
    Button1: TButton;
    CheckBox1: TCheckBox;
    Memo1: TMemo;
    Label1: TLabel;
    grpRadix: TRadioGroup;
    procedure Button1Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure nrComm1AfterReceive(Com: TObject; Buffer: Pointer;
      Received: Cardinal);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(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.nrComm1AfterReceive(Com: TObject; Buffer: Pointer;
  Received: Cardinal);
var i:integer;
    s:string;
begin
  s:='';

  case grpRadix.ItemIndex of
    0:  for i:=0 to Received-1
          do s:=s+IntToStr(Byte(PAnsiChar(Buffer)[i]))+' ';
    1:  for i:=0 to Received-1
          do s:=s+'$'+IntToHex(Byte(PAnsiChar(Buffer)[i]),2)+' ';
  end;

  Memo1.Text:=Memo1.Text+s;
end;

end.
