Gurus,
I have a file with the below content:
ALT_ATF2_B0_MAP [UINT(16),(1,5)] 5557 ; 5557
: 7075 ; 7075
: 7075 ; 7075
: 7075 ; 7075
: 7075 ; 7075
ALT_ATF2_B1_MAP [UINT(16),(1,5)] 10250 ; 10250
: 12621 ; 12621
: 12621 ; 12621
: 12621 ; 12621
: 12621 ; 12621
ALT_ATF2_B2_MAP [UINT(16),(1,5)] 4776 ; 4776
: 5692 ; 5692
: 5692 ; 5692
: 5692 ; 5692
: 5692 ; 5692
ALT_ATF2_VEHICLE_SPEED_MAP_VTD [UINT(16),(1,5)] 0 ; 0
: 640 ; 640
: 1280 ; 1280
: 2944 ; 2944
: 5760 ; 5760
ALT_COMP_EAC_A1 [INT(16)] 12205 ; 12205
ALT_COMP_EAC_A2 [INT(16)] 4072 ; 4072
ALT_COMP_EAC_B0 [INT(16)] 7674 ; 7674
ALT_COMP_EAC_B1 [INT(16)] 14221 ; 14221
ALT_COMP_EAC_B2 [INT(16)] 6606 ; 6606
ALT_COMP_EAC_BOOST [INT(16)] 164 ; 20.5
In the above file, I need to parse and read only those lines which have ",(" as delimiter for e.x
ALT_ATF2_VEHICLE_SPEED_MAP_VTD [UINT(16),(1,5)] 0 ; 0
Once we encounter this string, I need to do the following:
1) Store the first string in that line to a variable e.x ALT_ATF2_VEHICLE_SPEEAD_MAP_VTD needs to be stored in a variable
2) Secondly, at the end of the line there are 0; 0 and there are 4 more lines below this line. All are part of one entry. For E.x
ALT_ATF2_VEHICLE_SPEED_MAP_VTD [UINT(16),(1,5)] 0 ; 0
: 640 ; 640
: 1280 ; 1280
: 2944 ; 2944
: 5760 ; 5760
In the above, after we store ALT_ATF2_VEHICLE_SPEED_MAP_VTD in one variable. This corresponds to a property name in our software and has to be assigned with an array of values, which are nothing but 0, 640, 1280, 2944, 5760. These have to be the first values in the set ( for e.x 640; 640 => we need to store the first 640 only in the array).
We need to get all the first values into an array till we see another totally independent line entry like ALT_COMP_EAC_A1 [INT(16)] 12205 ; 12205
Once the values are obtained, we can use our Software API's to set the property with the obtained set of array of values.
Appreciate if anyone can help me with the parsing logic as I am finding it difficult to code.