05-18-2006 08:05 PM
05-19-2006 05:08 AM
Are you sure that you are trapping EVENT_COMMIT only? It seems that your callback is fired by different events: EVENT_GOT_FOCUS, EVENT_LEFT_CLICK, EVENT_VAL_CHANGED, and finally EVENT_COMMIT: this is consistent with the control having updated on the 3rd execution (EVENT_VAL_CHANGED) and not before.
Check that your callback has the usual switch (event) + case EVENT_COMMIT structure or a simpler if (event != EVENT_COMMIT) return 0; statement.
05-19-2006 06:18 AM
Thanks for the response. I am almost too embarrassed to admit the cause of the error! here goes. I am checking for the COMMIT as I always do when i don't care about others:
int CVICALLBACK buttons (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
if (event = EVENT_COMMIT) {
GetCtrlVal (pMain, PANEL_ALT, &alt);
switch (control) {...
As soon as i pasted my code into this message window, the single = stood out like a sore thumb. The program in question is tiny, so has presumably always been running 4 times or so on every click without my noticing until I put break pts in. I blame having to program in other languages concurrently. The CVI compiler picks up lazy missed semi-colons, but its perfectly happy with the above, of course. Oh well...
05-19-2006 07:32 AM
A little tip I learned ages ago is to put the constant on the left hand side when comparing a variable with a constant. So
if (EVENT_COMMIT == event) ...
is valid, whereas
if (EVENT_COMMIT = event) ...
will cause a compilation error.
Seems trivial, but get in the habit and it helps a lot.
05-19-2006 07:56 AM
In CVI 6 if you look under Options==>Build Options==> in the compiler warnings section on the upper right you can select Detect assignments in conditional expressions and CVI will trap this for you. There are also the common choices to allow the compiler to trap for sign mismatch, unreachable code, and unreferenced variables.
05-19-2006 08:08 AM
05-19-2006 08:19 AM
05-19-2006 08:22 AM
05-19-2006 08:26 AM
05-22-2006 10:50 AM