(Gast)
n/a Beiträge
|
Re: Internet to Listview
15. Aug 2009, 21:19
Delphi-Quellcode:
function Explode(const Separator, S :String; Limit :Integer = 0): TDynStringArray;
var
SepLen: Integer;
F, P: PChar;
begin
SetLength(Result, 0);
if (S = '') or (Limit < 0) then
Exit;
if Separator = '' then
begin
SetLength(Result, 1);
Result[0] := S;
Exit;
end;
SepLen := Length(Separator);
P := PChar(S);
while P^ <> #0 do
begin
F := P;
P := AnsiStrPos(P, PChar(Separator));
if (P = nil) or ((Limit > 0) and (Length(Result) = Limit - 1)) then
P := StrEnd(F);
SetLength(Result, Length(Result) + 1);
SetString(Result[High(Result)], F, P - F);
F := P;
if P = Separator then
SetLength(Result, Length(Result) + 1);
while (P^ <> #0) and (P - F < SepLen) do
Inc(P);
end;
end;
procedure TForm6.Button3Click(Sender: TObject);
var
Maps : string;
LI : TListItem;
StrArr : TDynStringArray;
begin
if Form1.Client.Connected = false then
begin
Form1.Client.Connect(3000);
end;
Form1.Client.WriteLn('Maplist');
repeat
Maps := Form1.Client.ReadLn;
if Length(Maps) > 0 then
begin
Maplist.Clear;
StrArr := Explode('|', Maps);
LI := Maplist.Items.Add;
LI.Caption := StrArr[2];
LI.SubItems.Add(StrArr[4]);
LI.SubItems.Add(StrArr[3]);
i := i+1;
end;
until
i = StrToInt(StrArr[1]);
Form1.Client.Disconnect;
end;
procedure TForm6.FormCreate(Sender: TObject);
begin
i := 1;
end;
end.
|
|
Zitat
|