LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Config ini file trouble with Write key Setpoint[] = [520,85]

Solved!
Go to solution

@Bacil83 wrote:

section and key I can do it, but the problem is the values must be in square brackets. 

And exactly why "must" the values be in square brackets?   And if there's a good reason, why "must" you wedge that non-standard syntax into an INI file format?

 

Life gets easier when you accept standard formats and function libraries as-is rather than fighting against them.  (Maybe not an option in your case, but from afar this is reminding me of the old:  "Doc, my back hurts when I put on my socks" -> "Well, then stop wearing socks").  It strikes me that there's a decision to be made:

INI format or square brackets?   Pick one.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 11 of 17
(706 Views)

@Kevin_Price wrote:

@Bacil83 wrote:

section and key I can do it, but the problem is the values must be in square brackets. 

And exactly why "must" the values be in square brackets?   And if there's a good reason, why "must" you wedge that non-standard syntax into an INI file format?

 

Life gets easier when you accept standard formats and function libraries as-is rather than fighting against them. 


AFAIK, There's no ini file standard.  And I've searched extensively.

 

There are dozens of dialects, differing on all levels of the ini file structure. For instance some ini file parsers support a global scope. Some automatically merge multiple sections with the same name. Some (NI) accept comments behind the values, but have no way to get or set them... And so on...

Message 12 of 17
(685 Views)

there are different scenarios and I need to be able to change voltage or condition and write to ini file. 

 

Bacil83_0-1651737457434.png

 

0 Kudos
Message 13 of 17
(678 Views)

wiebe@CARYA wrote:

@Kevin_Price wrote:

@Bacil83 wrote:

section and key I can do it, but the problem is the values must be in square brackets. 

And exactly why "must" the values be in square brackets?   And if there's a good reason, why "must" you wedge that non-standard syntax into an INI file format?

 

Life gets easier when you accept standard formats and function libraries as-is rather than fighting against them. 


AFAIK, There's no ini file standard.  And I've searched extensively.

 

There are dozens of dialects, differing on all levels of the ini file structure. For instance some ini file parsers support a global scope. Some automatically merge multiple sections with the same name. Some (NI) accept comments behind the values, but have no way to get or set them... And so on...


It's even looser than the RS-232 recommended standard.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 14 of 17
(666 Views)

@Bacil83 wrote:

there are different scenarios and I need to be able to change voltage or condition and write to ini file. 


The options are:

+ Live with quoted strings and use LV's library

+ Modify LV's library or use another library

+ Make a library yourself

 

With the library I linked you can either

1) read the keys as strings, and use scan from string \ format into string. (Put this in 2 VIs)

2) create a child and overwrite string to array and array to string so it adds [ and ]

3) read the keys as strings, and use string to array and array to string and add [ and ]. (Put this in 2 VIs)

4) modify the library so it suits your needs

 

I'd go for option 1, 2 or 3... Option 4 won't allow updating the library to benefit from new features and bug fixes (not that I have time to make them).

 

Another option would be to 'preprocess' the file to remove [] from the key name and values. However, NI's library doesn't allow opening a ini file from a string (OoTB anyway), so you'd need to save the file (to a copy).

0 Kudos
Message 15 of 17
(641 Views)

@Bacil83 wrote:

there are different scenarios and I need to be able to change voltage or condition and write to ini file. 

 

Bacil83_0-1651737457434.png


Part of the problem could be the keys with [] in it.

 

IIRC, LV's library doesn't handle that very well.

 

I know my library does handle that (better), ever sections can have [] in it:

 

[Pressure [Bar]]

 

Keys (probably) can't start with [ though. It might still work if there\s no ] and\or = in the line.

0 Kudos
Message 16 of 17
(636 Views)
Solution
Accepted by topic author Bacil83

Bacil83_0-1652341732181.png

Simple but works.

0 Kudos
Message 17 of 17
(601 Views)