09-21-2012 08:30 AM
I am quite new with Labwindows.
I need to control a lot of 32-bit registers by using buttons to set or reset each bits.
(It would be so complicated to manage each button by CALLBACK function).
Is there a simple way to controll array of buttons in Labwindows ? Or is there even a concept for "array of buttons" ?
Like in Labview with array and buttons as boolean variables.
09-21-2012 08:50 AM - edited 09-21-2012 09:12 AM
This depends on the version of CVI you have; CVI 2012 provides control arrays (http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/uiref/programming_with_control_arrays/ But even in earlier versions you can use one callback for several controls.
09-21-2012 08:58 AM - edited 09-21-2012 09:03 AM
If you are using CVI 2010 or later you can use arrays of controls which can help you in this issue: here a tip on using them
EDIT Wolfgang preceded me often!
Going a little bit further on his idea of a single callback for several controls, you can add to the controls appropriate callbackData with which can taylor the behaviour of the callback. Suppose you install a single callback on 32 buttons and add the bit index as callbackData on each of then with SetCtrlAttribute (..., ..., ATTR_CALLBACK_DATA, (void *)index); with index from 1 to 32: when you enter the callback you can simply read the callbackData you receive to immediately have the index of the bit to manipulate. The callbackData can only be assigned programmatically, you cannot set it in the UIR editor.
09-21-2012 09:07 AM
Thank for ur reply.
I am using CVI 2010. And i dont see how to assign a callback function to a control array.
Is it possible to control the buttons like a array of boolean variables?
09-21-2012 09:23 AM - edited 09-21-2012 09:25 AM
An alternative to using the callback data as suggested by Roberto is to simply check for the control id:
int CVICALLBACK DipSwitchButtonCallback (int panel, int ctrl, int event, void *cb, int e1, int e2)
{
switch (ctrl)
This could be further simplified if the controls are built programmatically. But since you have CVI2010 you might try the control array...