07-29-2013 09:59 AM
Hi guys, I'm working on a small c# program, which using the interface provided by LabVIEW. And I know that, using lv.SetControlValue(name, value) can set a variable just on the front panel. But in my case, there're several clusters on the front panel. So it confused me how to set the variables in these clusters. For example there's a cluster named clusterA, and a variable in it named valueA, I've tried something like this:
lv.SetControlValue("clusterA.valueA",1);
but it totally not work. Anyone has some experience about this stuff? Thanks a lot!! 😄
Solved! Go to Solution.
07-29-2013 10:05 AM
I assume the full cluster is the item you can access this way, but i've never tried.
/Y
07-29-2013 11:06 AM
LabVIEW clusters are represented as Typedefs, so you have to declare ClusterA as the typedef you define.
07-31-2013 07:33 AM
Hey guys, thanks a lot for all your reply. I just find a simply way to solve this porblem. For example, there a cluster named "ClusterA", and there are only two control values in it, which are: an int value named "IntA" (default value IntA = 10)and a string value named "StringA" (default value StringA = "abc"). In C# if you invoke the method:
var clusterA = (Array) vi.GetControlValue("ClusterA");
you will get an Array looks like: clusterA = {10, "abc"}; Then if you want to change IntA to 123, you just need to do:
clusterA.SetValue(123, 0); // 123 is the value, 0 is the index of IntA in the array clusterA, after this clusterA = {123, "abc"}
After this, you just need to give the array back to LabVIEW by using:
vi.SetControlValue("ClusterA", clusterA);
and now see the panel in you LabVIEW, the IntA is changed.