unit UMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 =
class(TForm)
JobList: TListBox;
JobMemo: TMemo;
procedure Button1Click(Sender: TObject);
procedure JobListClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
procedure LoadJobList(aFileName:
String; aLB:TListBox);
procedure JobListChanged(idx:Integer);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
LoadJobList('
C:\Test.txt', JobList);
end;
procedure TForm1.LoadJobList(aFileName:
String; aLB:TListBox);
var sl:TStringlist; si:Integer;
NewJob:Boolean;
begin
JobList.Clear;
sl:=TStringlist.Create;
sl.LoadFromFile('
C:\Test.txt');
NewJob:=False;
for si:=0
to sl.Count-1
do
if AnsiUppercase(Trim(sl.Strings[si]))='
STELLE'
then NewJob:=True
else begin
if NewJob
then
begin
JobList.Items.AddObject(sl.Strings[si], TStringList.Create);
NewJob:=False;
end;
TStringList(JobList.Items.Objects[JobList.Items.Count-1]).Add(sl.Strings[si])
end;
sl.Free;
end;
procedure TForm1.JobListClick(Sender: TObject);
begin
JobListChanged(JobList.ItemIndex);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
LoadJobList('
C:\Test.txt', JobList);
JobList.ItemIndex:=0;
JobListChanged(JobList.ItemIndex);
end;
procedure TForm1.JobListChanged(idx: Integer);
begin
JobMemo.Lines.Assign(TStringList(JobList.Items.Objects[idx]));
end;
end.