LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modification to Write Configuration .ini file

I have found one of the annoying things about Labview's configuration file VI's is that when the configuration file is written, all spacing between sections is eliminated making it hard to read, even if the spacing was there to begin with when the file was read.  For example, I would like the file to look like
 
[Header1]
key1=value1
key2=value2
 
[Header2]
key3=value3
key4=value4
 
But it comes out looking like:
 
[Header1]
key1=value1
key2=value2
[Header2]
key3=value3
key4=value4
 
making it harder to read.
 
I made a modification to the file Config Data to String.vi which is located \vi.lib\UTILITY\config.llb\
Make a backup copy of \vi.lib\UTILITY\config.llb\Config Data to String.vi and replace the file in the config.llb with the attachment (saved as LV 8.0).
 
What I did was any time a section header is to be written to the file, I preceded it with another CRLF character so that it creates a blank line just before the section header.  To keep from having an extra blank line at the beginning of the .ini file, it does not create the CRLF there.
 
I hope others will find this modification useful.
Message 1 of 12
(4,796 Views)
The idea itself is great, but I don't like the idea of changing vi.lib files (for several reasons).
I didn't look at your code, but I assume that at least in this case, the resulting files will still be processed fine by machines which don't have this modification, so it's probably not as bad, but I still don't like it.

You should probably go to the Product Suggestion Center and tell NI about this idea.

___________________
Try to take over the world!
Message 2 of 12
(4,774 Views)


@tst wrote:
The idea itself is great, but I don't like the idea of changing vi.lib files (for several reasons).
I didn't look at your code, but I assume that at least in this case, the resulting files will still be processed fine by machines which don't have this modification, so it's probably not as bad, but I still don't like it.

You should probably go to the Product Suggestion Center and tell NI about this idea.


I agree about not trying to change the vi.lib files.  It gets into modifying code that is rather deeply embedded about 3 or 4 sub-vi's down.  By my testing, machines without the modification do handle the files just fine.  The alternative would be to create a backup copy of the whole library and rename the files and use my own versions instead. I've recently installed the OpenG files and looked into them.  I like the functionality they provide to be able to store and retrieve clusters of configuration data.  Of course they have NI's write configuration files at the heart as well, so if they link to the original VI library then they will generate the same .ini files missing the extra lines that I like.


@tst wrote:

You should probably go to the Product Suggestion Center and tell NI about this idea.


Thanks, I already did this some time ago when I created a test VI to just read and close an .ini file.  I found that without setting the "write configuration file" flag in the close config file VI (which defaults to True), the whole file got rewritten even though nothing had changed.  That's how I stumbled across this loss of blank lines thing.

I hope NI will look into that suggestion and add it to the config file VI library in the future.  It would probably need to be implemented with a flag that says "Add blank lines?" that would default to False so that the original behavior of the VI could be maintained.  Since the VI that controls the appearance of the file is a few layers deeper than Close config file VI, that flag would have to be passed through a couple of sub-VI's.

Thanks for your feedback.

Message Edited by Ravens Fan on 09-22-2007 03:22 PM

Message 3 of 12
(4,770 Views)
I, too, was bothered by it and didn't want to have to modify vi.lb files.  This was the VI I wrote.  Before I close the INI file, I grab the Section names to pass into this VI and run this after I close the INI file, causing LV to write out the sections improperly.
Message 4 of 12
(4,765 Views)


@Ravens Fan wrote:

I've recently installed the OpenG files and looked into them.  I like the functionality they provide to be able to store and retrieve clusters of configuration data.  Of course they have NI's write configuration files at the heart as well, so if they link to the original VI library then they will generate the same .ini files missing the extra lines that I like.

They do use the original library, so you're right and they will have the same problem.

As you said, let's hope NI implements this as well.

___________________
Try to take over the world!
Message 5 of 12
(4,764 Views)
By the way, here's an example of how something like this might break - as far as I know, only Windows uses CRLF as the end-of-line char. What will happen if you use the files on other platforms? I don't know. Probably nothing, but we can't know for sure until we check or at least think about it.

___________________
Try to take over the world!
Message 6 of 12
(4,762 Views)


@tst wrote:
By the way, here's an example of how something like this might break - as far as I know, only Windows uses CRLF as the end-of-line char. What will happen if you use the files on other platforms? I don't know. Probably nothing, but we can't know for sure until we check or at least think about it.


That could be.  It wouldn't bother me because we use only Windows computers, and only write LV programs for our own in house purposes.  Thus I would have no way to test it on other platforms.

Although, if this was a problem, I think the current config file VI's would have a problem as well because the VI's are already using the CRLF as the end of line character.

Message 7 of 12
(4,737 Views)
Actually, the config VIs perform a "Convert EOL" operation, so as long as you're using an EOL constant you will be fine, and since you seem to be doing that it should be OK.

I would have to concur that replacing VIs that ship with LabVIEW is a bad idea. What happens if you need to reinstall LabVIEW and you forget to replace the VI? What happens if you leave, and the next person has to reinstall LabVIEW or install it on a new machine, and doesn't know that they need to replace a function? The best thing to do is to have your own Config File write that you use and you save it with the project, and don't mess with the LabVIEW VIs.
Message 8 of 12
(4,704 Views)

Was just about to write something similar myself when on a whim I checked to see if the behavior had changed.  I don't know when this was resolved but as of LabVIEW 2013 SP1 the config.llb\Write Key.vi adds an extra EOL to provide space between the sections (even if the incoming sections were unspaced).  Thanks, blue!


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
0 Kudos
Message 9 of 12
(3,764 Views)

This was something that was changed in the Config Files behavior, sometime before 2013.  I want to say it was quite a few years back.  I'll guess around LV 2009, but I don't specifically remember.

0 Kudos
Message 10 of 12
(3,761 Views)