LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
JB

Comments in configuration file (*.ini)

Status: New

Enhance the Configuration File VIs with a Write Comment.vi that allows to add comments to the configuration without any workaround.

 

Configuration File VIs.jpg

5 Comments
JB
Trusted Enthusiast
Trusted Enthusiast
The possibility to insert one or more empty lines (before a section) would also be useful and much appreciated.
Mark_Yedinak
Trusted Enthusiast
In addition, any comments that are already in the configuration file should be preserved when writing it back out. It is quite frustrating to create a nice example ini file for a user with comments explaining the options only to have them disapper as soon as the file is saved by the application.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
tst
Knight of NI Knight of NI
Knight of NI

LV 2009 has refactored config VIs. If memory serves, they do not delete existing comments, but someone would have to check to make sure.


___________________
Try to take over the world!
hockey2o
Member

Hi All,

 

Although this is not an ideal solution to adding comments / sections. The workaround I made was to:

 

1) make a type def of all my sections I want

2) Use Open/Create/Replace File to pre-write all sections with comments

    - make sure to have the correct format for sections  [] -->   [Test Details]

    example:

[Test Details]

;This section is for test information

;==========================

 

[Analog Inputs]

;here are the channels that were loaded for the test

 

3) Use Open Config Data to write in all the keys under the correct sections

 

 

wiebe@CARYA
Knight of NI

There is some support for comments in ini files. I doubt much people will know about this, and it is, arguably, fairly useless. It's also not the comment as people would like it to be. But I'll share this, maybe someone will find it useful, or amusing.

 

[section]

key= 123 ; comment

 

This works. The key can be written as integer, and the comment persists! The comment can also be read by reading the string value.

 

However, writing this comment value isn't possible. Even writing a raw string will result in a quoted string, where the comment is included between the quotes.

 

The ini file internals have a separate space for key comments. It's just never exposed in the API...

 

I'm all for adding support for comments. Writing my own ini file library, I know it's not that easy. It's not just adding, you'll probably want to have full control over comment, empty lines, keys and sections. For instance, add an empty line, but only if there isn't one already. It's not trivial to design an API that supports everything.