I use .ini files for alot of my configuration setups and like to add comments after the key value for future reference and clarity.
The problem is that if you write to the .ini file, all comments formatting (i.e. white space) is removed resulting in a .ini file that looks like a bomb has gone off in it.
Below is a snapshot of before and after the write for clarity:
Ive spoken to tech support and they confirmed that due to the nature of how the VIs are written this is the default behaviour. For clarity and full understanding I have included their response below:
I've been looking through the source code for the config file vi's and I've found where the tabs are disappearing. During the open config file function, the existing keys are parsed. This includes trimming any whitespace, which is why all your neatly aligned columns with tabs are disappearing, in the general case.
This can be overcome by modifying the file. The config files are all found in <LabVIEW>/vi.lib/Utility/config.llb/NI_LVConfig.lvlib.
In this library you will need to modify "Parse Key Value Pair.vi". Remove the "trim whitespace" function in the false case, which is currently removing whitespace before the comment. This will lead to all the whitespace remaining.
However, this will only work for keys which are not edited. When you write a key, this all changes. At the low level, the "Add Key.vi" is doing the formatting of the key. In here, you can see in the true>true>true case that there is space added between value and comment, which simply reformats the key to have 4 space characters before the comment. You could change this space constant to tab constant (maybe just have 3 of them), which would preserve most of what you are intending to keep. It will be slightly subject to the length of text affecting the tab alignment. If you need to sort this, you could use a bit of code which reads the string length and decides how many tabs to insert.
This method will work, however it is laborious and time consuming. For me personally it would be a great addition if there were a boolean control that allowed me to set whether to preserve the original formatting or not (True by default). You could even argue that there is no need to have the option to turn it on/off, simply preserve the original format by default then edit the original document after if you so wish.
Any comments or thoughts on this would be appreciated.
Regards
Mitch
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.