LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

inifile multiple items with same name

Solved!
Go to solution

Hello,

I have a parameter file similar to an ini-file. I can read it with inifile from the toolslib.

One section [SPLINE] has many, variable number of, lines that all start with DATA=. These data line are read as a string. The content is 3 values as input for some spline interpolation.

 

The labwindows inifile parser can read it and it can write it. The number of items for the section [SPLINE] equals the number of DATA-lines. When writing it, it recreates the [SPLINE] section with multiple items that all start as DATA =

 

Now I want to read subsequently each of these DATA-items, retrieve the three values, and put these in some arrays. 

The Ini_Get functions have as input a sectionname and an itemname. So when I use Ini_GetPointerToString, I always get  the first occurance of this itemname i.e. always the first line.

How do I get the second and third ... string ?

 

Regards, Jos 

 

I am using Labwindows CVI 8.0 for Windows

I am using the inifile parser from toolslib\toolbox

The data from Ini_WriteToFile looks like:

[MOTOR]
MOTORNUMBER = 4
APPLICATION = 0    -25.0     28.0      0.000   1.0    0.0     0.0
WAVELENGTH = 41     0.000   45.000    0.000   1.0    0.01 1.0
BANDWIDTH = 42  -25.000   20.000  -24.960   1.0    0.01    1.0
DEPOLARIZER = 43    -6.0     95.0      0.000   1.0    0.3     2.0

[SPLINE]
DATA = 240.3 ,  0.006 , -42.0  ; Zemax*/
DATA = 253.7 ,  5.034 , -42.85  ; High output Hg100 spectraal lamp*/
DATA = 280.4 , 12.396 , -44.7  ; High output Hg100 spectraal lamp*/
DATA = 296.8 , 15.761 , -45.1  ; High output Hg100 spectraal lamp*/
DATA = 334.2 , 21.389 , -47.2  ; High output Hg100 spectraal lamp*/
DATA = 404.7 , 27.680 , -50.4  ; High output Hg100 spectraal lamp*/

0 Kudos
Message 1 of 4
(4,272 Views)

This might be beyond the capabilities of the CVI Ini_ instrument, but the native Windows equivalents can handle it. Check out GetPrivateProfileSection() in the SDK.

 

JR

0 Kudos
Message 2 of 4
(4,269 Views)

Hi,

 

If you really want to use that library, call the Ini_ReadGeneric function with a custom reader function pointer.

Here, you need to code the reader function according to your needs.

 

But who needs the Ini_ library once you wrote a reader function.

Hence, I recommend writing a small function that reads the i-th DATA line and return the readings.

 

If you want, you can use the informational functions from Ini_ library to read the number of sections, tags, etc. as a helper to your custom reader.

S. Eren BALCI
IMESTEK
0 Kudos
Message 3 of 4
(4,262 Views)
Solution
Accepted by topic author JGS

Hello,

 

Thanks to both of you.

 

Because the ini-library was able to export the full data set, including multiple DATA-keys, I had some hope that there was an easy way to use this library. From your comments, it's not usefull to search for a work-around.

 

Meanwhile I have found another iniparser (http://ndevilla.free.fr/iniparser/). It does not "support"  double keys but I probably can adapt it for my application. If not so, than I will take some snippets from both the labwindows library and this second example, and have to build my own.

 

Regards, Jos

 

0 Kudos
Message 4 of 4
(4,235 Views)