unit uTListBeispielUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TV2Request =
record
RequestType: TV2RequestType;
Res: integer;
URL:
string;
LocalFile:
string;
HTTPContent:
string;
RequestVars: TStringList;
end;
TV2RequestList =
class (TList)
function GetItem (
const Index: integer): TV2Request;
procedure AddItem (
const U: TV2Request);
procedure InsItem (
const Index: integer;
const U: TV2Request);
procedure DelItem (
const Index: integer);
procedure SetItem (
const Index: integer;
const U: TV2Request);
procedure ClearList;
public
destructor Destroy;
override;
end;
TForm1 =
class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
List: TV2RequestList;
implementation
{$R *.dfm}
destructor TV2RequestList.Destroy;
begin
ClearList;
inherited;
end;
procedure TV2RequestList.ClearList;
begin
while Count > 0
do delItem(Count-1);
end;
function TV2RequestList.GetItem (
const Index: integer): TV2Request;
var
V: ^TV2Request;
begin
V:= Items[
Index];
Result:= V^;
end;
procedure TV2RequestList.SetItem (
const Index: integer;
const U: TV2Request);
var
V: ^TV2Request;
begin
V:= Items[
Index];
V^:= U;
end;
procedure TV2RequestList.AddItem (
const U: TV2Request);
var
V: ^TV2Request;
begin
New (V);
V^:= U;
V.RequestVars:= TStringList.Create;
Add(V);
end;
procedure TV2RequestList.InsItem (
const Index: integer;
const U: TV2Request);
var
V: ^TV2Request;
begin
New (V);
V^:= U;
V.RequestVars:= TStringList.Create;
Insert(
Index, V);
end;
procedure TV2RequestList.DelItem (
const Index: integer);
var
V: ^TV2Request;
begin
V:= Items[
Index];
V.RequestVars.Free;
Dispose(V);
Delete(
Index);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
List:= TV2RequestList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
List.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
I: integer;
Request: TV2Request;
begin
for I:= 1
to 10
do
List.AddItem(Request);
end;
end.