Results 1 to 2 of 2

Thread: Does D7 have RTTI?

  1. #1

    Does D7 have RTTI?

    Hello,
    should RTTI work on Delphi 7 (running on Win XP)?

    Code:
    unit functions;
    
    interface
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      SysUtils, RTTI, TypInfo;
    
    type
      TSampleRecord = record
        SomeInt: Integer;
        SomeStr: String;
        SomeFloat: Single;
      end;
    
    implementation
    
    function GetField(Rec: TValue; const FieldName: String): String;
    var
      Context: TRTTIContext;
      RTTIRecord: TRTTIRecordType;
      RecField: TRTTIField;
      RecValue: TValue;
    begin
      if (Rec.Kind = tkRecord) then
      begin
        RTTIRecord := Context.GetType(Rec.TypeInfo).AsRecord;
        RecField := RTTIRecord.GetField(FieldName);
    
        RecValue := RecField.GetValue(Rec.GetReferenceToRawData);
        Result := RecValue.ToString();
    
        if (RecValue.Kind = tkFloat) then
          Result := Format('%.4f', [RecValue.AsExtended]);
      end;
    end;
    
    
    end.
    Taken from here and modify (I need to include it into program to access record member dynamically).

    Error:
    [Fatal Error] functions.pas(10): File not found: 'RTTI.dcu'

    What am I doing wrong?

  2. #2

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •