LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading keys --> Array --> Cluster?

Trying to shrink some rather large vi diagrams used to read configuration parameters from ini's. No issues putting the key names in an array then using autoindex to pull in the data. My question is after I get the data read into another array how do I get it into a cluster by name? Currently I convert the array to a cluster but the cluster doesn't have any names so I rebundle into my cluster. Seems like I'm doing an extra step that doesn't need to be done.

 

Opinions / Ideas welcome.

 

 

0 Kudos
Message 1 of 6
(3,355 Views)

If you are able to use the OpenG library (I know in a lot of corporate situations people aren't) they have some tools that allow "ini files" to be created directly from a cluster with suitably named controls, then when read back repopulate a similar control. I had created a method similar to theirs, but it had "special cases" all over, where theirs handles pretty much everything, arrays, enums, etc. Just a thought. Otherwise the brute force method you are doing is about the only way. Of course any changes ...

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 6
(3,345 Views)

If your cluster elements were all of the same datatype then you could just do this:

0 Kudos
Message 3 of 6
(3,315 Views)

Of course they aren't all the same type; that would be far to simple. I have a little of everything; the snippet was just from one sub-vi. I had the ini loads broken up in sub vi's for each section. I do like that technique and I have added your example to my little stash of hints.

 

Poking around the OpenG and MGI pallets I think the Read/Write anything will do what I need while allowing simple maintainance. I'm just always a bit concerned about using 3rd party stuff.

 

 

0 Kudos
Message 4 of 6
(3,308 Views)

F1_Fan,

 

"OpenG Variant Configuration File VIs"  is a great set of functions for dealing with ini's.  The best part is that it will work with type def'd clusters.

0 Kudos
Message 5 of 6
(3,290 Views)

I highly recommend the OpenG VIs in general and the variant config VIs in particular. They work extremely well.

 

Here are a couple of less obvious points regarding the two:

 

  1. The MGI VIs are a lot faster, because the OpenG VIs rely on the NI config VIs, which allow you to edit specific sections in an INI file, etc., whereas the MGI VI simply overwrites the whole file.
  2. The MGI VIs rely on some code which is in only available in LV 8.0 and later.
  3. The OpenG VIs will fail to load the cluster if one of your cluster elements in an array of LVOOP objects, due to the way the type descriptor recognizes the object. I haven't tried the same thing with the MGI VI (edit - this may have actually been fixed with more recent versions of the OpenG code, but I haven't looked into it recently).

___________________
Try to take over the world!
0 Kudos
Message 6 of 6
(3,247 Views)