01-06-2022 06:07 AM
Hello,
Looking for a tool to read and save the ini input I found MGI's read write anything. However, I could not find any sample files. So after a few tries it worked. But I think there might be a more elegant way than mine. Furthermore the enum is still causing problems. Maybe someone here can help me.
Best regards
Solved! Go to Solution.
01-06-2022 06:37 AM
Commenting specifically about the use of MGI R/W Anything:
- I've used this library a lot and never needed to wire up the format specifier input.
- I probably wouldn't use "ini" as a section name since I typically also use ".ini" as the file extension. That's just a preference though
- don't ignore the error outs!
- it's sometimes handy to set the 'Use Supplied' input to True when calling MGI Read Anything. Then only the cluster elements that are explicitly defined in the INI file get replaced.
Overall though, you're basically doing it right. You made your cluster a typedef and you set your section name explicitly.
One thing to note: unfortunately, MGI INI files don't play nice with native LabVIEW INI file functions. MGI requires *no whitespace* surrounding the assignment '=' sign. The native functions surround the '=' with single space characters, which make MGI fail for that item. Once you choose between MGI and native LabVIEW functions for your INI files, make it an all-or-nothing choice.
-Kevin P
01-06-2022 10:56 AM
One thing to consider if you use the MGI R/W Anything is that as Kevin mentioned, it is very picky about white space. If humans will be modifying the file in a text editor I would probably chose the NI ini VIs. They are more forgiving about the exact format in the file. I have been burned using the MGI R/W Anything when humans have modified the file in a text editor.
01-06-2022 12:21 PM
01-07-2022 01:03 AM
Thank you, for yours fast answers.
As mentioned before, there is still a problem with the enum. The saved value is not written back to the enum control element.
01-07-2022 03:18 AM
1) Attach the VI.
Are the Enums the same (data in the same order)? - please list Strings array
I would suspect that if you haven't typedef'd the enum, the enum is probably in a different order in the 2 clusters.
It appears both clusters are type defs.
While I use MGI for configs, I am moving away from storing enums in the config. I store a Ring in the config Write Cluster, and convert it to an Enum for use in the code. (And before anyone else points it out, Enums and Rings default to different values when they hit the limits so you have to write some code for the data change).
This allows me to have a flexible UI and change the (Ring) text for the user - adding and removing new features as I want, but keep the Enum in the BD code and therefore have self documenting code, without the headache of what happens when a feature relying on a value is obsolete and the enum text is no longer available from the file.
James
01-08-2022 10:29 AM
@James: The Vi is in the first post already available.
01-10-2022 03:20 AM
@Heino wrote:
@James: The Vi is in the first post already available.
🙈 Sorry Heino.
- I can't reproduce this bug. I know I've got the MGI functions, but I also know they've been ever so slightly tweaked on our system so I can't install a virgin MGI toolkit ang get the same effect as the config file functions I have here. So I can tell you with tweaks to a few files (I think last time I loaded there were only 4 file different) the MGI toolkit can be made to play nicely. (Don't have time to look right now, and probably confidential which files we've tweaked)
James
01-10-2022 04:11 AM
Note: if one uses a Package and find it has issues are needs tweaking to work well, you should try contacting the authors of the package so that improvements can be incorporated in the publicly-available version and made available to everyone.
01-10-2022 06:27 AM
@drjdpowell wrote:
Note: if one uses a Package and find it has issues are needs tweaking to work well, you should try contacting the authors of the package so that improvements can be incorporated in the publicly-available version and made available to everyone.
Makes sense - but I don't know who tweaked it when - it was before my time here, so I assumed it was tweaked for a specific purpose here.
I'll have a look later this week. I don't think MGI has been updated in a few years (but I could be wrong).
James