Re: [fpc-pascal] Coercing record fields together

2018-07-10 Thread Martin
On 09/07/2018 18:22, Ryan Joseph wrote: Could I do some RTL magic on a record to loop over its fields and set them to another record by name? In the example below I want to set all the fields in TRecA to matching named fields in TRecB. Just curious if we can do this automatically using RTL. t

Re: [fpc-pascal] Coercing record fields together

2018-07-09 Thread Ralf Quint
On 7/9/2018 9:22 AM, Ryan Joseph wrote: Could I do some RTL magic on a record to loop over its fields and set them to another record by name? In the example below I want to set all the fields in TRecA to matching named fields in TRecB. Just curious if we can do this automatically using RTL. t

Re: [fpc-pascal] Coercing record fields together

2018-07-09 Thread Ryan Joseph
> On Jul 9, 2018, at 11:57 AM, gabor wrote: > > Hi. > Probably can be done with RTTI (1), enumerators (2) and generics (3) together. > > 1. https://stackoverflow.com/questions/27803383/fpc-rtti-on-records > 2. http://wiki.freepascal.org/for-in_loop#Traversing_container > 3. http://wiki.freepas

Re: [fpc-pascal] Coercing record fields together

2018-07-09 Thread gabor
Hi. Probably can be done with RTTI (1), enumerators (2) and generics (3) together. 1. https://stackoverflow.com/questions/27803383/fpc-rtti-on-records 2. http://wiki.freepascal.org/for-in_loop#Traversing_container 3. http://wiki.freepascal.org/Generics Michał. W dniu 2018-07-09 o 18:22, Ryan

Re: [fpc-pascal] Coercing record fields together

2018-07-09 Thread DaWorm
Just because someone is bound to suggest it, might as well be me. type TRecA = record a: string; b: string; end; type TRecB = record A: TRecA; c: integer; d: integer; end; RecB.A := Re

[fpc-pascal] Coercing record fields together

2018-07-09 Thread Ryan Joseph
Could I do some RTL magic on a record to loop over its fields and set them to another record by name? In the example below I want to set all the fields in TRecA to matching named fields in TRecB. Just curious if we can do this automatically using RTL. type TRecA = record