01-26-2018 04:08 AM
It is possible read a ini file with duplicate names on keys?
Example:
menu =first
subMenu =Temperature "0.5;5;1"
subMenu = Pressure "0;5;0.4852"
subMenu = Flow "0;5;1.2350"
subMenu =Mass "Serial"
I always get the same value for all key 'submenu'.
Labiew show me:
[Section]->menu
[key]-> subMenu =Temperature "0.5;5;1"
[key]-> subMenu = Temperature "0.5;5;1"
[key]-> subMenu = Temperature "0.5;5;1"
[key]-> subMenu =Temperature "0.5;5;1"
Always the same value
01-26-2018 04:14 AM - edited 01-26-2018 04:17 AM
01-26-2018 04:17 AM
@jawier130 wrote:
It is possible read a ini file with duplicate names on keys?
Example:
menu =first
subMenu =Temperature "0.5;5;1"
subMenu = Pressure "0;5;0.4852"
subMenu = Flow "0;5;1.2350"
subMenu =Mass "Serial"
I always get the same value for all key 'submenu'.
Labiew show me:
[Section]->menu
[key]-> subMenu =Temperature "0.5;5;1"
[key]-> subMenu = Temperature "0.5;5;1"
[key]-> subMenu = Temperature "0.5;5;1"
[key]-> subMenu =Temperature "0.5;5;1"
Always the same value
The ini function will always take the first match, so no.
What you could do is have a key for Submenu with a list "submenu = temperature, pressure, flow, mass"
Read this list and then read in those keys "Temperature = 0.5;5;1" and so on.
/Y
01-26-2018 04:19 AM
Another alternative is to have the section submenu, get the key-list and read all those keys
[submenu]
Temperature = "0.5;5;1"
Pressure = "0;5;0.4852"
Flow = "0;5;1.2350"
Mass = "Serial"
01-29-2018 09:27 AM
Thanks. But the .ini file is from another manufacturer, and i can not modify it. (I would do it but is very hard mod all files for all machines).
01-29-2018 09:36 AM
01-29-2018 10:29 AM - edited 01-29-2018 10:32 AM
It's possible using the OpenG Read Section Cluster function. The trick is to enclose it in a cluster and to unbundle it after the section cluster is read.Here is an example of how I use it:
In the ini file:
[runs-1-2]
data.<size(s)> = "3"
data 0.RunNumber = "1"
data 0.veloc = "60"
data 0.accel = "61"
data 0.targetPos = "3723"
data 1.RunNumber = "2"
data 1.veloc = "60"
data 1.accel = "61"
data 1.targetPos = "-4500"
data 2.RunNumber = "3"
data 2.veloc = "60"
data 2.accel = "61"
data 2.targetPos = "3723"
Loading code:
Ben64
edit: of course you will need to modify the ini file to fit this pattern, if you can't then you will have to parse the file as already said.
01-29-2018 04:39 PM
That doesn't look like a standard config (ini) file. You probably have to parse it out yourself.
01-29-2018 04:48 PM
@GerdW wrote:
Hi jawier,
no, you can't have duplicate keys (with different values) in one section!
One solution would be to keep an index in the key name like submenu01, submenu02, …
I've seen someone parse this out in a WHILE loop where they started with Test00 and use the [i] in the WHILE loop as a suffix (with leading zero). The parameters for each test were indexed into an array. You knew you were done when it couldn't find the key, so you threw out the last element in the array. That way, you didn't even have to know how many tests there were.
01-30-2018 06:04 AM
@billko wrote:
@GerdW wrote:
Hi jawier,
no, you can't have duplicate keys (with different values) in one section!
One solution would be to keep an index in the key name like submenu01, submenu02, …
I've seen someone parse this out in a WHILE loop where they started with Test00 and use the [i] in the WHILE loop as a suffix (with leading zero). The parameters for each test were indexed into an array. You knew you were done when it couldn't find the key, so you threw out the last element in the array. That way, you didn't even have to know how many tests there were.
I use Get Key Names and then iterate over the keys. If necessary, I can apply a filter with a FOR loop.