01-05-2012 10:02 AM
I have a program that contains 6 clusters of the same structure. I'd like to have a for loop to initialize the clusters to default values in stead of wiring 6 times to 6 different clusters. I've been thinking to programmably reference them by their string name, and then use an enum type to loop through their names. Is there a way to reference the cluster by name programmably?
01-05-2012 10:16 AM
You can get a list of front panel objects from teh FP property and then find the controls with the names you want.
SInce the refs to the objects will be generic array you will have to cast the refs so look over this nugget on using control references (stop after you find what you want, the nugget gets dirty at teh end).
Have fun!
Ben
01-05-2012 02:01 PM
You can start at this by creating cluster of references or array of references. To define the cluster of references on the BD, create the ctrl reference, then create a constant from the reference to use in the cluster definition. If using array you'll get a coercsion dot due to different data type of the array elements. You can use Label.Text to get the ctrl name, or array the names, search for the name to process.
Below is a paste to get started.
01-05-2012 03:13 PM
You could also use the Ctrl Val.Set method (VI class). Leave the VI reference unwired so it acts on 'This VI'. This lets you reference a control by its name (Label).
01-06-2012 08:54 AM
There you have it 3 different ways to reference cluster ctrl by string name. 1, FP property, 2, ctrl property 3, invoke method. Using the FP property output an array of ctrl references (no need to for defining the cluster by name as I did). Use invoke method, you need to know the name of the ctrl for input to the set ctrl method.