05-04-2022 09:20 AM
@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
05-05-2022 02:51 AM
@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...
05-05-2022 03:00 AM
there are different scenarios and I need to be able to change voltage or condition and write to ini file.
05-05-2022 09:21 AM
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.
05-06-2022 03:13 AM - edited 05-06-2022 03:44 AM
@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).
05-06-2022 03:41 AM
@Bacil83 wrote:
there are different scenarios and I need to be able to change voltage or condition and write to ini file.
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.
05-12-2022 02:49 AM
Simple but works.