LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create named cluster out of cfg file

How to read one Section and the associated Keys of a cfg file and build a cluster labelled with the section name and all the controls inside that cluster labelled with the Keys names? The goal is to be able to use the unbundle by name function to read values.
0 Kudos
Message 1 of 7
(3,838 Views)
I only see the hard way.
That is: use "Bundle by name" and have a constant of the cluster you want to build (a template) wired at the
middle terminal.
Then you'll have to use the ini-file vi's and read and wire the key values to the bundle inputs.

There may be several ways to process the different keys in a loop, but a named cluster is a constant thing and I do not see a way to generate it dynamicly .

Gabi
7.1 -- 2013
CLA
0 Kudos
Message 2 of 7
(3,838 Views)
Actually, you can just use that constant and a Bundle function. This actually makes it easier so that you have all possible cluster elements to wire to and then just use a case structure if the config file does not have all of the settings.

Randy Hoskin
Applications Engineer
National Instruments
http://www.ni.com/ask
0 Kudos
Message 3 of 7
(3,838 Views)
Thank you for your solution. (ref. "How to create named cluster out of cfg file")
Unfortunately it seem that there is no way to programmatically create or rename an object in run time.
I developp quite big applications with state machine technique.
I have one major shift register "pipe" that contain all named variables informations.
I modify the content of those variables, in any state, with the bundle and unbundle by name functions.
If, at least, I could create named dummy constant prior to get into the main while function and renamed them afterward it would be great!
0 Kudos
Message 4 of 7
(3,838 Views)
Randy,

I have the same question but could not figure out a solution. Would you provide an example?

Thanks!

Daniel
0 Kudos
Message 5 of 7
(3,838 Views)
You cannot dynamically rename a cluster element at run-time. You need to define the cluster (Data types and names), and then populate it in a sub-vi. After this you can read in as you wish and access by name.

The bottom line is that you cannot perform your wish for an unknown cfg file. When you know your cfg file, you can hard-wire the appropriate cluster and then step by step call the cfg file vis to fill the appropriate cluster elements.

In the following example, a cluster is filled by name. Even though the cluster constant used as template does not show all names, they are there (right click the individual constant parts and shoose "show names"). These names must be defined before run-time to ensure the output cluster is defined.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 6 of 7
(3,838 Views)
I had a similar wish and I solved it with the xml functions. You still have a readable ASCII-file for your configuration. It's not that nice to understand in the first view, but it save a lot of coding and I prefer it because you get more information. (put a enumeration control in your cluster and give it a try)

Henrik
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Download All
Message 7 of 7
(3,838 Views)