unit Flughafen;
interface
uses
StdCtrls, ExtCtrls, Classes;
type
TFlughafen =
class
private
vLabel1: TLabel;
vSearch: TTImer;
vEnabled: Boolean;
vInterval: Integer;
vText:
String;
Actual:
Array of Char;
Zeiger: Integer;
ActChar: Char;
procedure SetEnabled(Status: Boolean);
procedure SetInterval(Value: Integer);
procedure SetText(Value:
String);
procedure Start;
function GetStart(Character: Char): Char;
procedure SearchTimer(Sender: TObject);
public
constructor Create(AOwner: TComponent);
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(AOwner: TComponent);
begin
vSearch := TTimer.Create(AOwner);
vSearch.OnTimer := SearchTimer;
vSearch.Enabled := False;
vSearch.Interval := 21;
end;
destructor TFlughafen.Destroy;
begin
vSearch.Free;
SetLength(Actual, 0);
end;
procedure TFlughafen.SetEnabled(Status: Boolean);
begin
if (
not vEnabled)
and (Status)
then
vSearch.Enabled := True
else if (
not Status)
then
vSearch.Enabled := False;
vEnabled := Status;
if vEnabled
then
Start;
end;
procedure TFlughafen.SetInterval(Value: Integer);
begin
vSearch.Interval := Value;
end;
procedure TFlughafen.SetText(Value:
String);
begin
vText := Value;
Start;
end;
procedure TFlughafen.Start;
begin
SetLength(Actual, Length(vText));
Zeiger := 0;
ActChar := GetStart(vText[Zeiger+1]);
end;
function TFlughafen.GetStart(Character: Char): Char;
begin
case (Character)
of
#65..#90: result := #65;
#97..#122: result := #97;
#48..#57: result := #48;
#32: result := #32;
#0..#9: result := #0;
#10: result := #10;
#11..#31: result := #0;
#33..#47: result := #33;
#58..#64: result := #33;
#91..#96: result := #91;
else
result := #123;
end;
end;
procedure TFlughafen.SearchTimer(Sender: TObject);
var
i: Integer;
begin
Actual[Zeiger] := ActChar;
Inc(ActChar);
vLabel1.Caption := '
';
for i := 0
to Length(Actual) - 1
do
vLabel1.Caption := vLabel1.Caption + Actual[i];
if (Ord(vText[Zeiger+1]) < Ord(ActChar))
then
begin
Actual[Zeiger] := vText[Zeiger+1];
Inc(Zeiger);
ActChar := GetStart(vText[Zeiger+1]);
if (Zeiger > Length(vText))
then
vSearch.Enabled := False
end;
end;
end.