04-18-2019 10:24 PM
Hello:
I am trying to see if there is a faster or more elegant way of building an array of clusters from an ini file.
I have several products each with different configurations I am testing. I am storing the test limits inside an ini file and want to extra the information out to an array of clusters for test processing.
I am currently doing this in a unmaintainable way of just extracting the key-val pairs one by one.
Attached is the ini file I am parsing through.
Any suggestions to do this smarter or use another format maybe?
Thanks,
Mike
04-18-2019 10:31 PM
Take a look at MGI's Read/Write anything through JKI's VIPM tools network.
04-18-2019 11:46 PM
Using JSON files makes this a piece of cake assuming users do the editing and can tolerate the file format.
04-18-2019 11:48 PM
Hi BillMe,
Any how-to guides I can take a look to see how JSON can work in this case?
Thanks,
Mike
04-19-2019 12:03 PM
@Mwcmwc11 wrote:
Hi BillMe,
Any how-to guides I can take a look to see how JSON can work in this case?
Thanks,
Mike
1. Create cluster (looks like you've already done that)
2. Fill cluster with example values on a VI
3. Put down a "To JSON" node from the "Programming ► String ► Flatten/Unflatten String" palette
4. View the output JSON string and/or save it to a file
5. Modify it as needed (it's pretty obvious when looking at it)
6. On another VI, wire it into a "From JSON" node from the same palette along with your cluster
7. Test to see if the modified values come out OK
This help entry has a small amount of additional information on this.
04-19-2019 05:36 PM
If you want to stay with INI files, you can download the OpenG Variant Configuration File Library from VIPM. You can wire a cluster directly to create an INI file; there is a Read function also. See below.
Note that Voltage Range and Sampling Rate are Text Ring Controls, so the numbers are correct.
mcduff
04-20-2019 01:44 PM
@Mwcmwc11 wrote:I am trying to see if there is a faster or more elegant way of building an array of clusters from an ini file.
Definitely not faster, but still more elegant (and scalable!) would be to avoid all that duplicate code :D. Also make sure to use shift registers for the reference to protect for the case where the autoindexing array is empty.
04-21-2019 12:33 AM
Thank you all so much for the suggestions. I will take a look at all of them and see which fits our use-case the best.
Best Regards,
Mike
04-22-2019 12:19 PM
I like Mcduff's answer. I've used the OpenG library he's talking about, and it's so simple and intuitive that I actually LOL'd for real.
04-22-2019 01:20 PM
@billko wrote:
I like Mcduff's answer. I've used the OpenG library he's talking about, and it's so simple and intuitive that I actually LOL'd for real.
I guess it also depends if there is 20 years worth of legacy ini files using some unusual structure and if these need to be read too. Yes, if he has full control about the exact format and the writing and reading process, the openG library should work just fine. Have not looked inside them, so I am not sure about performance, but that should be irrelevant for typical sizes.