LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create a struct in LV?

I am trying to create the equivalent of a struct within LV.  I believe using a cluster is the route to go but I don't have much experience with them.  I would like to define and initialize a group of variables and then reference them by name further along in the code.  Any suggestions?

 

Thank you,

 

Stephen

0 Kudos
Message 1 of 6
(2,994 Views)

Oh man.... another text programmer Smiley Mad

 

I'm just kidding.


You can bundle the 'variables' into a cluster.

Then you can reference the cluster later in the code, and unbundle it to access the various parts.

 

cluster.PNG

Message Edited by Cory K on 06-05-2009 11:39 AM
Cory K
0 Kudos
Message 2 of 6
(2,991 Views)

char message[5]={'T','h','a','n','k','s'};

for (i; i <=5; i++)

{

    Write(message[i]);

};

 

Just kidding.  Thanks for that, I was trying to get this to work yesterday but it kept unbundling with only one name (the first variable placed in the cluster box). It was happening because I needed to name the rest of the variables before unbundling the cluster.

0 Kudos
Message 3 of 6
(2,984 Views)
When you use the 'unbundle' function, it should automatically resize itself to display all of the components.
Cory K
0 Kudos
Message 4 of 6
(2,968 Views)

Hi,

 

either resize the "unbundle by name" function to show more/all cluster elements or use the simple "unbundle" function which always shows all elements (but not by name).Or click the element name in the "unbundle by name" function to select a different element...

 

And please try to use LabView names (cluster instead of "struct", cluster element instead of "variable") as it will be a lot easier to understand your question and to provide help Smiley Wink

Message Edited by GerdW on 06-05-2009 08:12 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(2,961 Views)

STRUCT => CLUSTER;

it is usually best to make your clusters as typdefs and use bundle/unbundle by name

which is like

struct.field = value    this is bundle by name.

 

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 6 of 6
(2,959 Views)