LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing in ini file without destroying empty lines

Hello,

 

I'm trying to edit automatically (with a LB/CVI program) some items values of an ini file which is often edited by users but the empty lines  are deleted and they must stay (for visibility), is it possible with Labwindows/CVI ?

0 Kudos
Message 1 of 8
(1,759 Views)

With C (and thus with CVI) almost everything can be programmed Smiley Happy

0 Kudos
Message 2 of 8
(1,756 Views)

Additionally, I can confirm that CVI iniFile instrument does honor and maintain empty lines when it saves .INI files.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 8
(1,746 Views)

Maybe I forgot something, can you take a look to my code which replace some item's values of the ini file ? There is already items and values I just want to change them but all the empty lines of the file are deleted. (but the change of values work well)

0 Kudos
Message 4 of 8
(1,741 Views)

You only have to add Ini_ReadFromFile at the beginning of the process; this will permit you also to issue Ini_Putxx calls only for modified parameters and not for all of them.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 8
(1,732 Views)

Sorry I forgot to put it in the file but there is a Ini_ReadFromFile just after the "file=Ini_New(0)".

0 Kudos
Message 6 of 8
(1,718 Views)

Ok you're right: the IniFile instrument honors empty lines between sections but not those within a section (i.e. empty lines separating different items in a section).

 

From what I see, you have a couple alternatives at your hand:

  • Modify IniFile code to maintain empty lines in a section. I don't how whether it is possible or easy, but the instrument comes with the source code so you could try. I have to admit that I tried modifying that exact instrument in the past but eventually resolved not to follow on in that route due to the need to replicate the modifications on each new release or patch of CVI that could affect the instrument
  • Separate items with comment lines instead of empty lines. To obtain a comment line simply put a semicolon at the beginning of the line. Hint: it seems that only one line with a single semicolon is maintained in the process; you will need to add some character more in the lines to preserve them
  • Change your .INI file organization separating  items in different sections instead of having a single section with all the informations in it


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 7 of 8
(1,713 Views)

The only alternative I can do is to modify Inifile code I will check this.

Thank you for your help.

0 Kudos
Message 8 of 8
(1,706 Views)