title: Delphi: Parsing a record of unknown structure
body: <p>Is there a way to take a record and go through all its fields programatically without explicitly doing "Record.somefield"?</p>
  
  <p>What I want to do is a generalized function to save/load a record as an INI file so that I can add or remove fields from my record structure without having to rewrite the save/load functions each time I remove or add fields to the record.</p>
  
  <p>In other words I want to iterate in some way like this (pseudo code):</p>
  
  <p><code></p>
  
  <pre><code>THuman = record  
    age: integer;  
    country: string ;  
  end;  
  ...  
  myPerson: THuman;  
  ...  
      foreach Field in myPerson do
      begin
        if Field.value is String then ini.WriteString( 'Group', Field.Name, Field.value );
        if Field.value is integer then ini.WriteInteger( 'Group', Field.Name, Field.value );
      end;
  </code></pre>
  
  <p></code></p>
  
  <p>BTW, the reason I want to do this is because I can't save a typed filed when using non-bounded strings. Also it is beneficial to me that the files are human readable. So I am saving them and INI files.</p>