OK, I'm not sure if this is possible, but here goes. I've got a data file which contains lots of options for my program. E.g.
This file is basically a mirror of a user defined type:
I've got a function that reads each line and splits the data into the identifier (field name) and the value, storing it in another type. I then have a Select satement to put the data in the correct field:
This just seems a very inefficient way of doing this since the identifier from the data file is always the same name as the type field. Plus, the data file will end up with lots of field values and this will just be a massive Select statement plus I have to make sure I manually code in each field.
Is there any way of setting the type fields according the identifier? I need to be able to do something like:
Is it possible to do something like this? I'm having a slow brain day today so any help would be appreciated.
fieldName1: some data fieldName2: more data fieldName3: even more data etc.
This file is basically a mirror of a user defined type:
Type TMyData Field fieldName1$, fieldName2$, fieldName3$ 'etc... End Type
I've got a function that reads each line and splits the data into the identifier (field name) and the value, storing it in another type. I then have a Select satement to put the data in the correct field:
While Not Eof(dataFile) getFileOption(ReadLine(dataFile)) Select fopt.identifier$ Case "fieldName1" dat.fieldName1$ = fopt.value$ Case "fieldName2" dat.fieldName2$ = fopt.value$ Case "fieldName3" dat.fieldName3$ = fopt.value$ End Select Wend
This just seems a very inefficient way of doing this since the identifier from the data file is always the same name as the type field. Plus, the data file will end up with lots of field values and this will just be a massive Select statement plus I have to make sure I manually code in each field.
Is there any way of setting the type fields according the identifier? I need to be able to do something like:
(pseudo code) While Not Eof(dataFile) getFileOption(ReadLine(dataFile)) dat.[fopt.identifier$] = fopt.value$ Wend
Is it possible to do something like this? I'm having a slow brain day today so any help would be appreciated.