LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple text string display in one for/while loop

Hello,

 

I have around 700 text string displays in different tabs in my application which displays some angle values. I am using SetCtrlVal function to display the buffer contents. The problem is, I have 700 displays and I have to use 700 SetCtrlVal functiions to display them. Is any smart way to use one SetCtrlVal function in a while loop with variable constant names for text displays in the function parameter.

 

thanks,

 

Sandeep

0 Kudos
Message 1 of 5
(3,357 Views)

If you are using CVI2010 you can benefit from the control arrays facility.

 

Alternatively, you could create a list of control IDs and use it in a loop:

 

int   ctrls[10];

ctrls[0] = PANEL_CONTROL01;
ctrls[1] = PANEL_CONTROL02;
....
ctrls[9] = PANEL_CONTROL10;

 

for (i = 0; i < 10; i++) {
   sprintf (msg, "%.1f", angle[i]);
   SetCtrlVal (panelHandle, ctrls[i], stringArray[i]);
}

 

The alternative of using SetAttributeForCtrl or SetAttributeForList is not feasible in your case since you are using strings: these commands are powerful but can treat only integer values.

 



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?
Message 2 of 5
(3,290 Views)

Thanks Roberto. That should help.

One more question. I have some logic running which will tell me if the angle value is within a limit say +/- y. I want to color the text with red if the angle is out of limit else will be black. So I will have to use SetCtrlAttribute to change the text color. My question is that whether can I use this function same as SetCtrlVal you mentioned above?

 

Thanks,

 

Sandeep

0 Kudos
Message 3 of 5
(3,286 Views)

Yes, you can. You may have problems if the panel your controls are on is set as "Conform to system colors": in this case the code won't honour SetCtrlAttribute statement but will return no error.



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 4 of 5
(3,283 Views)

Thank you Roberto, I have disabled the "Conform to system colors" and works well. Thanks for the tip.

 

0 Kudos
Message 5 of 5
(3,280 Views)