unit MyClass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdHTTP;
const
Host = '
';
Port = '
';
type
GameList =
string;
GameItem =
string;
Game =
array of string;
Games =
array of GameItem;
THack =
class(TObject)
HTTP: TIdHTTP;
function GetGameList(): GameList;
function AnalysGameList(List:GameList): Games;
function GetGameNames(List:GameList):
string;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
implementation
function THack.GetGameList(): GameList;
var
list: GameList;
begin
//laden der GameList vom Server
try
list := HTTP.Get(Host + '
/server/login.php?action=list');
except
list := '
Error: IdHTTP - Fehler';
end;
Result := list;
end;
function THack.AnalysGameList(List:GameList): Games;
var
item: GameItem;
items: Games;
I: integer;
begin
//liest die Spiellieste aus und gibt alle spile in einer array zurück
I := 0;
while Pos(#13#10,List) <> 0
do
begin
item := copy(List,0,Pos(#13#10,List));
if not ( item = '
BOF' )
OR not ( item = '
EOF' )
then
begin
items[I] := item;
List := copy(List,Pos(#13#10,List),Length(List));
I := I + 1;
end;
end;
Result := items;
end;
function THack.GetGameNames(List: GameList):
string;
var
I: integer;
item: GameItem;
items:
string;
begin
//liest die Spiellieste aus und gibt alle spile in einem string zurück
I := 0;
while Pos(#13#10,List) <> 0
do
begin
item := copy(List,0,Pos(#13#10,List));
if not ( item = '
BOF' )
OR not ( item = '
EOF' )
then
begin
items := items + item + #13#10;
List := copy(List,Pos(#13#10,List),Length(List));
I := I + 1;
end;
end;
Result := items;
end;
end.