Einzelnen Beitrag anzeigen

Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.464 Beiträge
 
Delphi 12 Athens
 
#7

AW: Statisches array of Single (glFloat) - Exception

  Alt 29. Nov 2011, 10:05
Dann wird das aber etwas komplizierter:
Delphi-Quellcode:
interface

type
  THeapArray = array [0..3,0..65535] of Single;
  PHeapArray = ^THeapArray;

  IHeapArray = interface(IInterface)
    function GetHeapArray: PHeapArray;
    property HeapArray: PHeapArray read GetHeapArray;
  end;

  THeapRecord = record
  private
    FHeapArray: IHeapArray;
    function GetItems: PHeapArray;
  public
    property Items: PHeapArray read GetItems;
  end;

implementation

type
  THeapObject = class(TInterfacedObject, IHeapArray)
  private
    FItems: THeapArray;
  protected
    function GetHeapArray: PHeapArray;
  end;

{ THeapObject }

function THeapObject.GetHeapArray: PHeapArray;
begin
  Result := @FItems;
end;

{ THeapRecord }

function THeapRecord.GetItems: PHeapArray;
begin
  if not Assigned(FHeapArray) then
    FHeapArray := THeapObject.Create;

  Result := FHeapArray.HeapArray;
end;
Delphi-Quellcode:
procedure TForm1.ButtonTestClick(Sender: TObject);
var
  MyRecord: THeapRecord;
begin
  MyRecord.Items[2, 65000] := 1.456;

  ShowMessage(Format('Wert: %f', [MyRecord.Items[2, 65000]]));
end;
  Mit Zitat antworten Zitat