Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is no Rtti solution for your Delphi-7 version.</p> <p>If you don't want to implement @ain's suggestion with an array of pointers inside a record, here is a suggestion that uses a <a href="http://docwiki.embarcadero.com/RADStudio/XE3/en/Structured_Types#Variant_Parts_in_Records" rel="nofollow"><code>variant part in the record</code></a> to accomplish a similar thing. You can freely use <code>myStruct.AddrX</code> names for clarity in code, but also <code>myStruct.allAddresses[X-1]</code> to address the same field.</p> <pre><code>Type FreeStruct = record intExample : Integer; // not in the variant part case boolean of // Variant structure where the different parts overlap in memory true : ( Addr1 : Pointer; Addr2 : Pointer; Addr3 : Pointer); false : (allAddresses : array[0..2] of Pointer); end; procedure ClearFreeStruct( var AStruct : FreeStruct); var i: Integer; begin for i := 0 to High(AStruct.allAddresses) do begin // Dispose of allocated pointers end; end; </code></pre> <p>You can expand the structure with more pointers, but also include other fields (before the variant part).</p> <hr> <p>It is possible to use an array of pointers within your record without giving up clarity. By using an <code>enumeration</code>, it is possible to address each pointer with a relevant name.</p> <blockquote> <p>Example: myStruct.Addr[peAddr1]</p> </blockquote> <pre><code>Type PointerEnum = (peAddr1,peAddr2,peAddr3); FreeStruct = record intExample : Integer; Addr : array[PointerEnum] of Pointer; end; procedure ClearFreeStruct( var AStruct : FreeStruct); var pe : PointerEnum; begin for pe := Low(PointerEnum) to High(PointerEnum) do begin // Dispose(AStruct.Addr[pe]); end; end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload