LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing numeric control values using callback parameters

The callback function created by a numeric control also contains the parameters EventData1, EventData2 and callbackData. In the help I can't see any reference to the usage of these parameters with numeric controls (except for tables). As far as I can see they remain unused.

Is it possible to make one of these parameters contain the value of the control when called, so that is isn't necessary to do a getctrlval all the time?
0 Kudos
Message 1 of 3
(2,771 Views)
The eventdata1 and eventdata2 parameters are used for every control. They are used based primarilty on the event type, not the control type. There are some differences between controls, but mainly these parameters hold different information based on the event type. As for callbackData, you can set this to whatever you want using SetCtrlAttribute on the Callback Data attribute. However, you can't have it automatically map to some property or value of the control so it wouldn't save you the GetCtrlVal step.

Short answer, no, you can't map these parameters to automatically hold the value of the control.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 3
(2,771 Views)
eventData1 and eventData2 are parameters passed by CVI to the callback functions. The user (or programmer) doesn't set the values. eventData1 and eventData2 are only available in the callback function. See the comments for EVENT_COMMIT, etc., in userint.h to see the type of data they contain (based on the event that triggered the callback).
In the scheme of event driven programming, GetCtrlVal makes sense. You get the control's value when you need it based on some user-generated event.
If you have some control that sets a value that rarely changes but that you need to read often, you could store that value to a global. Initialize the global using GetCtrlVal when you start your program. Then, in the callback function for the control, create a case for EVENT_VAL_CHAN
GED and update the global there.
0 Kudos
Message 3 of 3
(2,771 Views)