Need help with - howto find struct field

View: New views
2 Messages — Rating Filter:   Alert me  

Need help with - howto find struct field

by Jan Kowalski-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I try to convert string to structure field. As example:

 function getRepF(argo,argn: string): boolean;
 begin
 ...
       dataA.'argn':=argo;
 ...
 end;

argn is a string with name of structure (dataA) field. Is there any
way to do that ? somethink like FindStructField ?

Please help!

Regards
faber
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: Need help with - howto find struct field

by Marco van de Voort :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In our previous episode, Jan Kowalski said:

> Hi, I try to convert string to structure field. As example:
>
>  function getRepF(argo,argn: string): boolean;
>  begin
>  ...
>        dataA.'argn':=argo;
>  ...
>  end;
>
> argn is a string with name of structure (dataA) field. Is there any
> way to do that ? somethink like FindStructField ?

In general: no. In compiled languages, identifier names are generally
eliminated in the compilation process.

There are remote cases possible for classes (RTTI/introspection), but these
are special cases. See the examples for e.g. unit typinfo.
 
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@...
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
LightInTheBox - Buy quality products at wholesale price!