From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Built array of clusters from INI file

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.

 

ini_to_Cluster.png

Attached is the ini file I am parsing through.

Any suggestions to do this smarter or use another format maybe?

 

Thanks,

Mike

0 Kudos
Message 1 of 11
(4,453 Views)

Take a look at MGI's Read/Write anything through JKI's VIPM  tools network.

Message 2 of 11
(4,450 Views)

Using JSON files makes this a piece of cake assuming users do the editing and can tolerate the file format.

0 Kudos
Message 3 of 11
(4,435 Views)

Hi BillMe,

Any how-to guides I can take a look to see how JSON can work in this case?

 

Thanks,

Mike

0 Kudos
Message 4 of 11
(4,432 Views)

@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.

 

Message 5 of 11
(4,408 Views)

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.

 

Snap48.png

 

Note that Voltage Range and Sampling Rate are Text Ring Controls, so the numbers are correct.

 

mcduff

Message 6 of 11
(4,394 Views)

@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.

 

CombineEm.png

Message 7 of 11
(4,382 Views)

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

0 Kudos
Message 8 of 11
(4,369 Views)

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.

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 9 of 11
(4,339 Views)

@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.

0 Kudos
Message 10 of 11
(4,328 Views)