unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SerialNG, StdCtrls, ComCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
RS232: TSerialPortNG;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
Edit1: TEdit;
UpDown1: TUpDown;
Label6: TLabel;
UpDown2: TUpDown;
Label7: TLabel;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure RS232RxClusterEvent(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
procedure UpDown2Click(Sender: TObject; Button: TUDBtnType);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
n: integer;
string1:
string[255];
string2:
string[255];
string3:
string[255];
string4:
string[255];
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
RS232.Active:=false;
memo1.clear;
label1.Caption:='
';
label2.Caption:='
';
label3.Caption:='
';
label4.Caption:='
';
label5.Color:= cllime;
label5.Caption:='
Speicher frei ';
updown1.Position:=1;
updown2.position:=1;
edit1.Text:='
1';
label6.Caption:='
';
n:=1;
RS232.Active:=true;
end;
procedure TForm1.RS232RxClusterEvent(Sender: TObject);
begin
case n
of
1..255:
begin
string1:= string1 + rs232.ReadNextClusterAsString;
label1.Caption:= inttostr(n);
end;
256..510:
begin
string2:= string2 + rs232.ReadNextClusterAsString;
label2.Caption:= inttostr(n-255);
end;
511..765:
begin
string3:= string3 + rs232.ReadNextClusterAsString;
label3.Caption:= inttostr(n-510);
end;
766..1020:
begin
string4:= string4 + rs232.ReadNextClusterAsString;
label4.Caption:= inttostr(n-765);
end;
1021:
begin
label5.Caption:= '
Speicher voll ';
label5.Color:= clred;
end;
end;
n:=n+1
end;
procedure TForm1.Button1Click(Sender: TObject);
var m: integer;
begin
memo1.Clear;
for m:=1
to 1023
do
case m
of
1..255: Memo1.Text:= Memo1.text + string1[m];
256..510: Memo1.Text:= Memo1.text + string2[m-255];
511..765: Memo1.text:= Memo1.text + string3[m-510];
766..1020: Memo1.text:= Memo1.text + string4[m-765];
end;
end;
procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
begin
edit1.Text:= inttostr(updown1.position);
updown2.Position:= updown1.Position;
case updown1.Position
of
1..255: label6.Caption:=(string1[updown1.position]);
256..510: label6.Caption:=(string2[updown1.position-255]);
511..765: label6.Caption:=(string3[updown1.position-511]);
766..1020: label6.Caption:=(string1[updown1.position-767]);
end;
end;
procedure TForm1.UpDown2Click(Sender: TObject; Button: TUDBtnType);
begin
edit1.Text:= inttostr(updown2.position);
updown1.Position:= updown2.Position;
case updown2.Position
of
1..255: label6.Caption:=(string1[updown1.position]);
256..510: label6.Caption:=(string2[updown1.position-255]);
511..765: label6.Caption:=(string3[updown1.position-511]);
766..1020: label6.Caption:=(string1[updown1.position-767]);
end;
end;
end.