Thema: Delphi Pointer :\

Einzelnen Beitrag anzeigen

Benutzerbild von maximov
maximov

Registriert seit: 2. Okt 2003
Ort: Hamburg
548 Beiträge
 
Delphi 2005 Professional
 
#25

Re: Pointer :\

  Alt 13. Aug 2004, 16:33
Na, ok:

Delphi-Quellcode:
Type
     TField = record
        way : byte;
        item : byte;
        tag : byte;
        flags : byte;
        ran : byte;
     end;


     TMatrix = array of array of TField;

     TMap = class(TDynaVisible)
     Private
       FMapFile: string;
       procedure SetMapFile(const Value: string);
     Public
       MapName : STring;
       Coment : String;
       Bounds : TPoint;
       Matrix : TMatrix;
       style : integer;
       mode : integer;
       TimeLimit : integer;
       GUID : STring;
       Creator : String;
       CreateDate : TDateTime;
 
       Function SetToBounds(xBounds: TPoint; NoKill: boolean = true):TPoint;
       procedure ReadData(reader : TReader); dynamic;
       procedure WriteData(writer : TWriter); dynamic;
       Function SaveToStream(stream : TStream):Boolean;
       Function LoadFromStream(stream : TStream):Boolean;
       Function LoadFromeFile(const fName: String):Boolean;
       Function SaveToFile(const fName: String):Boolean;

     published
       property iName : string read MapName;
       property iComent: string read Coment;
       property iStyle: integer read style;
       property iMode: integer read Mode;
       property iTimeLimit: integer read TimeLimit;
     end;


...

function TMap.SetToBounds(xBounds: TPoint; NoKill: boolean = true): TPoint;
// setzt die dynamische grössen des map-arrays.

function TMap.LoadFromeFile(const fName: String): Boolean;
var
  stream : TFileStream;
begin
  stream := TFileStream.Create(fname, fmOpenRead);
  try
    LoadFromStream(stream);
  finally
    stream.Free;
  end;
end;

function TMap.SaveToFile(const fName: String): Boolean;
var
  stream : TFileStream;
begin
  stream := TFileStream.Create(fname, fmCreate or fmOpenWrite);
  try
    SaveToStream(stream);
  finally
    stream.Free;
  end;
end;
Die bezeichner der felder und properties sind nicht sehr stardardmässig da der code schon sehr alt ist, aber einer meiner ersten schönen dynamischen streaming-versuche
mâxîmôv.

{KDT}
  Mit Zitat antworten Zitat