LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Initializing data in an Array of Clusters

First, thanks in advance for reading this request.
 
Second, the situation:
 
I am using an array of clusters for process control.
The cluster contains a boolean, a typedef ring control, and two numeric controls (doubles).
Depending upon the user-requested operation I need anywhere from four to 20 cluster elements in the array.
 
Raw data for the two numeric controls are contained as elements in three different input clusters.
Each numeric control in each array cluster can use from none to four elements from the input clusters with various additions and subtractions (no mults or divs).
The boolean and ring can be set as constants for each element based on the user request.
 
Third, the request:
 
Is there a simple way to initialize the values in the cluster (and hence the array) without having to run wires everywhere?
 
I have been writing embedded code and PC applications for many years and am only recently tackling LabView.
In C, I would create a structure of the four elements and then create and array of structures.
The initialization would require a few lines of code.
I have tried using formula nodes (perhaps incorrectly).  All they do is remove the Numeric blocks (like + and -), but they don't create the cluster.
 
I am sure that there is an easier way of accomplishing what I need to do, I am just too inexperienced to know what it is.
 
Any help or suggestions is welcome.
Thanks in advance.
 
0 Kudos
Message 1 of 4
(3,403 Views)
Create a cluster with the desired default values as diagram constant, wire it to "initialize array" and wire the desired array size.
 
The output will be the desired construct that you could write to e.g. a local variable of the target.
 
I hope I understood you correctly. If not, attach a small VI containing your array.
0 Kudos
Message 2 of 4
(3,400 Views)

Thanks for the thought, I think that is close to what I am already doing.

I use a cluster of the type that I need to create a series of "bundle by name" and use those bundles as the elements in the array.

From an aesthetic standpoint, I have wires criss-crossing and running everywhere through add and subtract functions.

 

I was just hoping that there was a textual way that I could use.

 

0 Kudos
Message 3 of 4
(3,386 Views)
LabVIEW is different from text based languages in more ways than just being graphical. A key difference is that LV uses a dataflow paradigm rather than the control flow used by text languages. It can be awkward at first, but once you get used to it, it can add power and versatility to your programming. Many times the "best" way to do something in LV is not a direct correlation with the comparable operation in a text language. Look through some of the examples and ask more questions. Look at the style guides that have been published.

Good programming requires both understanding of the problem you are trying to solve and the tools you have available.

If you post your program, someone will probably be able to offer suggsetions on ways to minimize your "spaghetti code."

This forum has lots of people who like to help.

Lynn
0 Kudos
Message 4 of 4
(3,379 Views)