Einzelnen Beitrag anzeigen

Dennis07

Registriert seit: 19. Sep 2011
Ort: Deutschland
482 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: Record-Array über Zeiger parsen

  Alt 2. Feb 2016, 06:13
Hm. Das ist ja seeeehr merkwürdig. Dieser Code geht indertat.
Bei mir geht ein ähnliches Beispiel aber nicht. Dann muss ich wohl den originalen Quelltext posten...

Delphi-Quellcode:
interface

type
  PCommand = ^TCommand;
  TCommand = record
    Name: Byte;
    Parameter: Pointer;
  end;
  TData = record
    Variables: array of Integer;
    Commands: array of PCommand;
  end;
  TMap = class
  private
    FData: TData;
    procedure LoadFromFile(const FileName: String);
  end;

implementation

procedure TMap.LoadFromFile(const FileName: String);
var
  Labels: array of PCommand;
  CurrentLabel: ^PCommand;
  Command: PCommand;
begin
  Labels := //...
  //Create empty last object for recognition
  SetLength(FData.Commands,Length(FData.Commands) + 1);
  //Replace label names in parameters with target addresses
  if Length(Labels) <> 0 then
  begin
    SetLength(Labels,Length(Labels) + 1);
    Command := PCommand(FData.Commands);
    while Command^.Parameter <> nil do
    begin
      if Command^.Name in [17,18] then
      begin
        //...
      end;
      Inc(Command);
    end;
  end;
end;
Dennis

Geändert von Dennis07 ( 2. Feb 2016 um 06:15 Uhr)
  Mit Zitat antworten Zitat