I am parsing an ascii data header file with obnoxiously human unreadable field names like:
structureName.manufacturer.modelNumber.serialNumber.hardwarePartID(6).hardwareAddresses(24).featureList(274).licensed = "1"
There are thousands of lines, and since this needs to be inspected by a human from time to time, I am reorganizing the information into a more readable and workable format, but I have run into a problem. I need only certain lines of data, and only if those lines exist. I have settled upon making a variable list of parameters I need (based on the specific application), and I have read the ascii text into structures with the same field names. The problem is when I have to assign these parsed parameter values into my new (readable) structure, I have to step through the list of field names.
I would like to be able to use dynamic field naming to make the assignments. For instance,
structureName.(fieldname) = parsedStructure.(manufacturer).(modelNumber). ...
However, this version of dot indexing (right side dynamic naming) is not supported. Neither is:
structureName.(fieldname) = parsedStructure.(manufacturer.modelNumber) ...
And, of course, the first thing I tried was using the dotted fieldnames as text:
parsedField = 'manufacturer.modelNumber.whateverNonsenseComesAfterThis';
structureName.(fieldname) = parsedStructure.(parsedField);
But using nested field names isn't supported either. Or at least, I haven't been able to figure out how to do it.
I can make it work with an eval call, but there are several reasons why that isn't a good idea, and I'd rather not stick with that solution. Basically, what I need to do is be able to step through a list of (hundreds of) required parameters, and for those that exist in the data, extract them into my new structure.