Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-04

enumerate record fields at runtime

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fabio Luis Girardi

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

Reply by email

Sven Barth
to Fabio Luis Girardi

Fabio Luis Girardi via fpc-pascal schrieb
am Di., 7. Apr. 2020, 14:58:

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

More is not possible as of now. Only once the Extended RTTI is supported this will be possible.

Regards,
Sven

Reply by email

Fabio Luis Girardi
to Sven Barth

Thanks for the clarification!

Sven Barth wrote 14 lines
Fabio Luis Girardi via fpc-pascal schrieb am Di., 7. Apr. 2020, 14:58: > > Using RTTI I can count the record fields, but until now, I can't find a > way to get the field names. > More is not possible as of now. Only once the Extended RTTI is supported this will be possible. Regards, Sven
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com

Reply by email