<p style="padding:0 0 0 0; margin:0 0 0 0;">Hi,</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">I used TFPObjectList only once, for visual component TECAccordion (https://wiki.lazarus.freepascal.org/Eye-Candy_Controls#TECAccordion). Each item of list is derived from TWinControl so it is possible to use it even for visual components (like TCollection).</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">However, in your case (records) I would rather use TFPGList from FGL unit:</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">1) add {$modeswitch ADVANCEDRECORDS}</p>
<div><span style="font-size: 10pt;">2) add FGL to uses</span></div>
<div><span style="font-size: 10pt;">3) define class operator =</span></div>
<div>
<div>test = record</div>
<div> Port :String;</div>
<div> Size :Byte;</div>
<div> Status :Word;</div>
<div> class operator = (A,B: test): Boolean;</div>
<div> End; </div>
<div>4) implement it</div>
<div>
<div>class operator test.=(A, B: test): Boolean;</div>
<div>begin</div>
<div> Result:=(A.Port=B.Port) and (A.Size=B.Size); // and ...</div>
<div>end; </div>
</div>
</div>
<p style="padding:0 0 0 0; margin:0 0 0 0;">5) define specialized list:</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> TMyL = specialize TFPGList<test>;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">6) create it</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> MyList: TMyL;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> ...</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> MyList:=TMyL.Create;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">Now you can work with it comfortably</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">MyList[1].Port:='abc';</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">V.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">______________________________________________________________<br />
> Od: "James Richters via fpc-pascal" <fpc-pascal@lists.freepascal.org><br />
> Komu: "'FPC-Pascal users discussions'" <fpc-pascal@lists.freepascal.org><br />
> Datum: 07.09.2020 01:08<br />
> Předmět: [fpc-pascal] TFPObjectlist example<br />
></p>
<br />
James<br />
<br />
_______________________________________________<br />
fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br />
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br />