[fpc-pascal] enumerate record fields at runtime

Fabio Luis Girardi fluisgirardi at gmail.com
Tue Apr 7 14:45:49 CEST 2020


Hi all!

To FPC developers: FPC trunk has a way to enumerate all record fields and
get their names?

For example:

type
  aRec = record
    a:String;
    b:integer;
    K:Int64;
    W:Single;
  end;

I want to do something like this:

for f in aRec.Fields do
  writeln(f.Name);

and get the output

a
b
K
W

I want a way to simple stream records to JSON, without the need of writing
a customized streamer for each record type.

Using RTTI I can count the record fields, but until now, I can't find a way
to get the field names.


Best regards,

Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada
http://www.pascalscada.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200407/e7b049fc/attachment.html>


More information about the fpc-pascal mailing list