[fpc-pascal] TFPObjectlist example

Vojtěch Čihák vojtech.cihak at atlas.cz
Tue Sep 8 16:29:04 CEST 2020


Hi,
 
some crippled formatting, so again:
 
However, in your case (records) I would rather use TFPGList from FGL unit:
 
1) add {$modeswitch ADVANCEDRECORDS}
 
2) add FGL to uses
3) define class operator =
test = record    Port :String;    Size :Byte;    Status :Word;    class operator = (A,B: test): Boolean;  End; 4) implement itclass operator test.=(A, B: test): Boolean;begin  Result:=(A.Port=B.Port) and (A.Size=B.Size);  // and ...end;   5) define specialized list:
 
  TMyL = specialize TFPGList<test>;
 
6) create it
 
  MyList: TMyL;
 
  ...
 
  MyList:=TMyL.Create;
 
Now you can work with it comfortably
 
MyList[1].Port:='abc';
 
V.
______________________________________________________________
> Od: "Vojtěch Čihák via fpc-pascal" <fpc-pascal at lists.freepascal.org>
> Komu: james at productionautomation.net, "FPC-Pascal users discussions" <fpc-pascal at lists.freepascal.org>
> Datum: 08.09.2020 16:21
> Předmět: Re: [fpc-pascal] TFPObjectlist example
>
______________________________________________________________
 > Od: "James Richters via fpc-pascal" <fpc-pascal at lists.freepascal.org>
 > Komu: "'FPC-Pascal users discussions'" <fpc-pascal at lists.freepascal.org>
 > Datum: 07.09.2020 01:08
 > Předmět: [fpc-pascal] TFPObjectlist example
 >

 James
 
 _______________________________________________
 fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
 https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
 
 
 ----------
 
 _______________________________________________
 fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
 https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal <https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200908/bbbaeedd/attachment.htm>


More information about the fpc-pascal mailing list