Access structure field names during run time
Posted: Sun Aug 23, 2015 12:48 am
Hi guys,
is there any possibility to access the names of a structure field during run time? I know, that the structure field are just used for specifying the offset at which the desired information is placed in the memory relative to the address of the structure variable. However, e.g. when using InsertJSONStructure(), the program obviously uses the structure field names for the corresponding JSON it generates. So I thought there has to be some way to implement this although I was not able to find anything here.
The specific case for which I want to use this is the following:
Which I obviously want to implement more efficiently by directly accessing the offset of the structure field by its name
is there any possibility to access the names of a structure field during run time? I know, that the structure field are just used for specifying the offset at which the desired information is placed in the memory relative to the address of the structure variable. However, e.g. when using InsertJSONStructure(), the program obviously uses the structure field names for the corresponding JSON it generates. So I thought there has to be some way to implement this although I was not able to find anything here.
The specific case for which I want to use this is the following:
Code: Select all
Select name$
Case "id"
offset = OffsetOf(struc\id)
Case "name"
offset = OffsetOf(struc\name$)
Case "value"
offset = OffsetOf(struc\value)
Case "other_stuff"
offset = OffsetOf(struc\other_stuff$)
Case "etc"
offset = OffsetOf(struc\etc$)
; ...
EndSelect