LabVIEW Idea Exchange

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

Add comment function to ini file

In ini (configuration) files it is desirable to commentout keys as well as add comments to Sections or Keys, thsi can be done with

;this is a comment

 

Why is there not functions for adding comments to an ini file

 

The functions I would like is

- Add comment to section/Key (if key is blank, the comments are added below the [section] tag)

 

I want this so that I can keep track of what the sections and keys are used for in a complex application or for putting notes into an ini (ie ;do not change this filed or ;valid values are 0-100)

 

The only method I see for this is to parse and write the comments manually of using a text file section. 

When I looked into the low level format of the ini files it is just a queue of clusters which keeps track of sections and key-value pairs, there is a comment filed but I dont see it ever used, was this a planned option that was never implemented.  I do not want to write my own since this now requires access to provate functions of the config libraray and I have been burned by this already (NI decides to make a function private and future code is broken).

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
7 Comments
JackDunaway
Trusted Enthusiast
falkpl
Trusted Enthusiast

Why does this not show up when I do a search?

 

Kudos to you.

 

This is such a simple feature it should have been here for years. 

 

Please merge this with the original request

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
JackDunaway
Trusted Enthusiast

falkpl wrote:

Why does this not show up when I do a search?


Among the other list of bugs in Idea Exchange, it appears searching for "comment" does not return results that have "comments" (notice the plural "s"). That's why your search does not turn up the other result... not your fault... and no Kudos to me, Kudos to some of these discussions below on how to make the Idea Exchange better:

 

http://forums.ni.com/ni/board/message?board.id=130&thread.id=7030&jump=true

http://forums.ni.com/ni/board/message?board.id=130&thread.id=7129&jump=true

http://forums.ni.com/ni/board/message?board.id=130&thread.id=6858&jump=true

http://forums.ni.com/ni/board/message?board.id=130&thread.id=7024&jump=true

http://forums.ni.com/ni/board/message?board.id=130&thread.id=6944&jump=true

 

 

Albert.Geven
Trusted Enthusiast

Hi Falkpl

 

I think you are wrong about that this is a simple addition. You are right about the read part but wrong about the write.

I did not look at the latest version that keeps blank lines but I know it is not as simple as you think.

We did this in our implementation of ini files and it involves keeping the original formatting and replacing new values for old contents. So although it is not difficult it is a complete change of model for implementation.

greetings from the Netherlands
falkpl
Trusted Enthusiast

All I was saying is that there is arleady a comment field in the (at least 2009) version for sections and infact it is even written to the string that goes to file but I dont see any where it is set with a function.  As for comments after a Key Value Pair this data is stored in a 2d array, why not just add the comments in the 3rd column and write it after the key value:

 

[Section] ;Comment

Key = Value ;Comment

 

with a new function that allows write key with comment.

 

This is not trivial but T can not even attempt it since it means overiding the default ini file functions.

Either way I would like to see the ability to add comments to an ini key.

 

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
G-Money
NI Employee (retired)

I am going to close this idea as duplicate since the other idea incorporates this functionality and has more kudos.

G-Money
NI Employee (retired)