LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Get Key Names.vi" reads comment lines too?

It seems, that the vi "Get Key Names.vi" reads comment lines of ini-file too. (Comment lines begin with ";" or "#".) Is it bug or a feature or something I do wrong?

"Get Key Names.vi" has to read all keys of a specified section. But a comment is not a key!
Message 1 of 12
(4,847 Views)

Hi bohm,

afaik this is not a bug. You have to filter this lines if you need.

Mike

0 Kudos
Message 2 of 12
(4,832 Views)
Yes, I did it.

In my opinion it's a bug. The programers simply overlooked comments in ini-files.
0 Kudos
Message 3 of 12
(4,815 Views)
It's a bug. Comments should not be returned. If you use the Windows API function, comments are not returned. So says Microsoft, so says the world. Smiley Very Happy
0 Kudos
Message 4 of 12
(4,813 Views)
Hi,

This problem has been already reported to R&D (#93725) for further investigation.  Thank you for the feedback. 

 
Balazs T.
National Instruments
Applications Engineer
Message 5 of 12
(4,765 Views)
What Windows API call are you referencing?
George M
National Instruments
0 Kudos
Message 6 of 12
(4,751 Views)
You can use either GetPrivateProfileSection or GetProfileSection (for the win.ini file). Although these functions return the key-value pairs, comments are not returned. See attached example.
Download All
Message 7 of 12
(4,734 Views)

I am working with a config file right now and have done so in the past.  I have to avoid putting comments in the ini file although I would like to.  I will be thankful when this bug (or feature) is fixed.  For the time being, I put my comments in the vi that creates the config file and in the vi that reads the file.

Another work around is to create a fake section and put comments on the next line.  Just ignore it when you read it in.  See the partial config file below:

[Comment]
This is a test comment.
[GPIB]

In the above, Comment is read as a section and the entire next line is read as a key with no value.  Just ignore any sections that are labled Comment.  It really doesn't cause any problems.

- tbob

Inventor of the WORM Global
Message 8 of 12
(4,681 Views)
There's also the (long-standing) bug that when the config VIs write out comments, the VIs append the text ="" at the end of the comment. I had reported this a long time ago, and it has never been fixed. At least as far as 8.2 is concerned. I have no idea if it's still in 8.5 because I don't have 8.5.
0 Kudos
Message 9 of 12
(4,679 Views)

Wow!

The last time I looked (LV 7.1) updating an ini file wiped out all of the comments. You mean we are allowed to use comments?!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 12
(4,674 Views)