Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.052 Beiträge
 
Delphi 12 Athens
 
#4

Re: Get count of members in record

  Alt 10. Jan 2010, 12:33
If you want to have such functionality, then you must implement it yourself.

Since Delphi 2010 it is could possibly even take the new RTTI support.




since Delphi 2006 / Turbo Delphi

Delphi-Quellcode:
TPerfFormattedData_PerfOS_Processor = record
  C1TransitionsPerSec: String;
  C2TransitionsPerSec: String;
  ...
  Timestamp_Sys100NS: String;
private
  function GetProp(i: Integer): String;
public
  property Prop[i: Integer]: String read GetProp;
end;
or

Delphi-Quellcode:
TPerfFormattedData_PerfOS_Processor = record
  C1TransitionsPerSec: String;
  C2TransitionsPerSec: String;
  ...
  Timestamp_Sys100NS: String;
end;

TPerfFormattedData_PerfOS_Processor_Helper = record helper for TPerfFormattedData_PerfOS_Processor
private
  function GetProp(i: Integer): String;
public
  property Prop[i: Integer]: String read GetProp;
end;
Delphi-Quellcode:
function TPerfFormattedData_PerfOS_Processor{_Helper}.GetProp(i: Integer): String;
begin
  case i of
    0: Result := C1TransitionsPerSec;
    1: Result := C2TransitionsPerSec;
    ...
    23: Result := Timestamp_Sys100NS;
    else Raise Exception.Create('invalid index');
  end;
end;
Neuste Erkenntnis:
Seit Pos einen dritten Parameter hat,
wird PoSex im Delphi viel seltener praktiziert.
  Mit Zitat antworten Zitat