LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

need help, parameter Problem

Hello
 
I hope you can understand my english 😄
 
my problem:
I have 7 Binary Switch in a function panel, Everyone's got another "on" value.
now i want that the summary of all switches is set in one integer named "total_value"
this "total_value" should be calculated in the c-programm.
 
what's the command for that?
 
THX PEACE
0 Kudos
Message 1 of 2
(2,945 Views)

There isn't a single command to obtain the value of multiple controls on a panel. Supposing that by "summary" you intend to assign each switch to a bit in final value, and since a bynary switch assumes only values 0 and 1 depending on its state, what you can do is the following:

int     val[7];    // The array of switch values
int     i;
int     totalVal = 0;

GetCtrlVal (panelHandle, PANEL_SWITCH0, &val[0]);
GetCtrlVal (panelHandle, PANEL_SWITCH1, &val[1]);
GetCtrlVal (panelHandle, PANEL_SWITCH2, &val[2]);
GetCtrlVal (panelHandle, PANEL_SWITCH3, &val[3]);
GetCtrlVal (panelHandle, PANEL_SWITCH4, &val[4]);
GetCtrlVal (panelHandle, PANEL_SWITCH5, &val[5]);
GetCtrlVal (panelHandle, PANEL_SWITCH6, &val[6]);
GetCtrlVal (panelHandle, PANEL_SWITCH7, &val[7]);
for (i = 0; i < 7; i++) totalVal += (val[i] << i)

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,924 Views)