I've been looking for this too.
My game will use some sort of INI-files, where there are blocks of data, while each block contains several lines of data (or parameters) like this:
When I'm reading this file, I check for a data-block (= "[Sector]").
When such a line is found, I read all following lines until there's an empty line.
But the issue is reading each line (I can do it already, but in a clumsy way).
For every line I read from the file, I split the word before the equal sign and the one after the sign into two variables: the first one is "ParameterName" and the second is "ParameterValue".
Then I try to find a match for the parametername (with a select case statement), where I put the value in the correct field of a type.
But it would be easier if I could use the content of the variable "ParameterName" as the fieldname.
Now I do this (NOTE: I use arrays of types to store my data):
If I just could use something like this:
then it would be simpler (of course the type must have the field where the ParameterName would point to).
The above line would use the content of the variable "ParameterName" (example: "Name") as the field-pointer (or how would you call it) and put the value (content) of "ParameterValue" in the Name-field of the type.
My game will use some sort of INI-files, where there are blocks of data, while each block contains several lines of data (or parameters) like this:
[Sector] Name = Sol system Description = This sector is the best know sector PositionX = 250 PositionY = 250 Race = Terrans [Sector] Name = Barnards star Description = This sector is an agricultural one PositionX = 200 PositionY = 180 Race = Aliens
When I'm reading this file, I check for a data-block (= "[Sector]").
When such a line is found, I read all following lines until there's an empty line.
But the issue is reading each line (I can do it already, but in a clumsy way).
For every line I read from the file, I split the word before the equal sign and the one after the sign into two variables: the first one is "ParameterName" and the second is "ParameterValue".
Then I try to find a match for the parametername (with a select case statement), where I put the value in the correct field of a type.
But it would be easier if I could use the content of the variable "ParameterName" as the fieldname.
Now I do this (NOTE: I use arrays of types to store my data):
Select ParameterName$
Case "Name"
ArraySectors(SectorNumber)\Name$ = ParameterValue$
Case "Description"
ArraySectors(SectorNumber)\Description$ = ParameterValue$
Case "PositionX"
ArraySectors(SectorNumber)\PositionX% = ParameterValue$
Case "PositionY"
ArraySectors(SectorNumber)\PositionY% = ParameterValue$
Case "Race"
ArraySectors(SectorNumber)\Race$ = ParameterValue$
End Select
If I just could use something like this:
ArraySectors(SectorNumber)\ParameterName$ = ParameterValue$
then it would be simpler (of course the type must have the field where the ParameterName would point to).
The above line would use the content of the variable "ParameterName" (example: "Name") as the field-pointer (or how would you call it) and put the value (content) of "ParameterValue" in the Name-field of the type.