unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
tLoopFunc =
Function(AString :
String) : Boolean;
type
tForLoopList =
class(TStringList)
private
{ Private-Deklarationen }
public
function DoLoop(AProc : tLoopFunc) : Boolean;
end;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function DieEigentlicheArbeit(AString :
String) : Boolean;
begin
if aString = '
x'
then begin
// mach noch was ...
Result := True;
end else Result := False;
end;
function DieAndereArbeit(AString :
String) : Boolean;
begin
if aString = '
x'
then begin
// mach noch was ....
ShowMessage('
Eine Zeile mit x');
Result := True;
end else Result := False;
end;
function tForLoopList.DoLoop(AProc : TLoopFunc) : Boolean;
var
i : Integer;
begin
Result := False;
if Not Assigned(AProc)
then Exit;
for i := 0
to Self.Count - 1
do begin
Result := AProc(Self[i]);
if Result
then Break;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sl : tForLoopList;
begin
sl := tForLoopList.Create;
// irgendwie jetzt für Inhalt in sl sorgen.
// sl.LoadFromFile('x.txt');
sl.Add('
x');
case sl.DoLoop(DieEigentlicheArbeit)
of
true : sl.DoLoop(DieAndereArbeit);
false : ShowMessage('
war nix');
end;
// Ergbenis eventuell abspeichern?
// sl.SaveToFile('x.txt');
sl.Free;
end;
end.