unit Flughafen;
interface
uses
StdCtrls, ExtCtrls, Classes;
type
TFlughafen =
class
private
vLabel1: TLabel;
vSearch: TTimer;
vEnabled: Boolean;
vInterval: Integer;
vText:
String;
procedure SetEnabled(Status: Boolean);
procedure SetInterval(Value: Integer);
procedure SetText(Value:
String);
function GetStart(Character: Char): Char;
procedure SearchTimer(Sender: TObject);
public
constructor Create(aLabel: TLabel);
destructor Destroy;
override;
property Output: TLabel
read vLabel1
write vLabel1;
property Enabled: Boolean
read vEnabled
write SetEnabled;
property Interval: Integer
read vInterval
write SetInterval;
property Text:
String read vText
write SetText;
end;
implementation
constructor TFlughafen.Create(aLabel: TLabel);
begin
vSearch := TTimer.Create(
nil);
vSearch.OnTimer := SearchTimer;
vSearch.Enabled := False;
vSearch.Interval := 21;
vLabel1:=aLabel;
end;
destructor TFlughafen.Destroy;
begin
vSearch.Free;
end;
procedure TFlughafen.SetEnabled(Status: Boolean);
begin
vEnabled := (Status)
and Length(vText)>0;
vSearch.Enabled := vEnabled;
end;
procedure TFlughafen.SetInterval(Value: Integer);
begin
vInterval := Value;
vSearch.Interval := Value;
end;
procedure TFlughafen.SetText(Value:
String);
begin
vText := Value;
vLabel1.Caption:='
';
end;
function TFlughafen.GetStart(Character: Char): Char;
begin
case Character
of
#0..#9: result := #0;
#10: result := #10;
#11..#31: result := #0;
#32: result := #32;
#33..#47: result := #33;
#48..#57: result := #48;
#58..#64: result := #33;
#65..#90: result := #65;
#91..#96: result := #91;
#97..#122: result := #97;
else
result := #123;
end;
end;
procedure TFlughafen.SearchTimer(Sender: TObject);
var
capt:
String;
len: Integer;
begin
capt:=vLabel1.Caption;
len:=Length(capt);
if (len=0)
or (capt[len]=vText[len])
then begin
if len=Length(vText)
then
vSearch.Enabled:=False
else
capt:=capt+GetStart(vText[len+1]);
end else
Inc(capt[len]);
vLabel1.Caption:=capt;
end;
end.