LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I read "Keys" from a Config File that have square brackets in them?

I'm using the "Read Key (String).vi" from the config.llb and I'm having a problem because the key names in my file have square brackets in them. I'm creating an VI to read certain pieces of the TestStand �StationGlobals.ini� file and array elements appear as %[0] = "blah blah blah". It looks like they're not getting recognized at all. Is there a way to handle this?
0 Kudos
Message 1 of 10
(4,277 Views)
John;

The configuration file you are mentioning will not work because the content do not follows the format the LabVIEW's ini VIs expect (LabVIEW User manual - Chapter 13). My suggestion will be to 1) make a backup copy of your configuration file to make sure you don't loose anything in the event of a mistake and 2) open the file in a text editor and manually delete the brackets of those items that are suppose to be a key name (hoping the configuration file is not hundreds of lines big).

Enrique
www.vartortech.com
Message 2 of 10
(4,277 Views)
Hi Jon! To read a key string containing a square bracket make sure the Read Raw String input to the read VI is set to true. I just verified this behaviour and can send you a couple VIs demonstrating it if you like. Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 10
(4,277 Views)
Enrique,
Thanks for your response. After reviewing the situation last night I came to the same conclusion. I opened, (searched and replaced) and then closed the file before using the config VIs. I was hoping there was a way to disable the square brackets that I didn't know about.
Thanks again,
John
0 Kudos
Message 4 of 10
(4,277 Views)
Mike,
Thanks for the response. I took a quick look at the config VIs again and didn't see the input you referenced. Unfortunately we're still using LV 5.1.1, is this a feature on the configure file VIs in version
of LabVIEW?
John
0 Kudos
Message 5 of 10
(4,277 Views)
Hmmm. I don't know. I use version 6.0.2 and the terminal is at the bottom in the center on the VIs I have. Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 10
(4,277 Views)
I was just looking at the code inside the configuration VIs and the way they work under V6 is that the Open VI actually reads the contents of the configuration file, parses it (in nice-platform independent G) and stores it in a fancy LV2-style global called the "Config Data Registry.vi". The routine that does the parsing is called "String to Config Data.vi". My gut reaction is that this code is going to be the same in your version because between sometime prior to V6 of LV, NI changed the location of a couple terminals on the low-level Match String function and it looks like when this code was originally written the terminals were in the old configuration.

In any case, if your square-bracket containing strings are getting lost, this is probib
ly where it's happening at. The other place to check is in the read VI itself. The V6 VI for reading the configuration registry is called "Config Data Get Key Value.vi". It's output is then further parsed by a function called "Parse Store String.vi" if the "read raw string?" input is set to False (the default position).

Given that all the code for these functions are written in LV, you should be able to fix your VIs to read the strings you have in the ini file now. Which IMHO is actually the way they should work.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 10
(4,277 Views)
Hi mike;

So far I've been unable to verify what you suggest. My understanding from the problem description is that John's configuration file looks like the one attached.
www.vartortech.com
0 Kudos
Message 8 of 10
(4,277 Views)
Ohhhhhhhh... Now I see what you mean. I didn't understand that the key name was in square brackets. Yes, that will cause a problem because of the way the code parses labels internally. The format of the file you sent will hose things up.

However, that is fixable by changing slightly the logic used in identifying section labels--as distinct from key labels.

Let me work on this for a bit. This can be done...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 9 of 10
(4,277 Views)
Here guys try this. I rewrote the parsing routine to handle keys that contain square brackets (it's also a lot more efficient).

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 10
(4,277 Views)