Thema: Delphi Struktur einer Class

Einzelnen Beitrag anzeigen

Benutzerbild von Desmulator
Desmulator

Registriert seit: 3. Mai 2007
Ort: Bonn
169 Beiträge
 
#1

Struktur einer Class

  Alt 14. Aug 2007, 15:50
Hallo,
ich schreibe an einer eigenen classe, jedoch bin ich atm etwas rat los...

also meine class:
Delphi-Quellcode:
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.
wie ihr seht, werden in der kallse neue variablen typen deklariert ( Game, GameList uws... ) wie kann ich die in der HauptForm nutzen, bzw, wo müssen wie stehen, damit es functioniert. auserdem wie kann ich die functionen benutzen?

Desmulator

[edit=Phoenix]Sorry, aber das überflüssige c im Titel in Struktur hat echt wehgetan. Mfg, Phoenix[/edit]
Lars
  Mit Zitat antworten Zitat