LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in SetAttributeForCtrls ?

Hello all,
compiling the following fails because the 3rd parameter is declared as int
(and I want a function):

SetAttributeForCtrls (Pnl, ATTR_CALLBACK_FUNCTION_POINTER, cb_SamplePopup,
4,
CtrlPrecision, CtrlFormat, CtrlPadding, CtrlInc);

Shouldn't that function be able to take all the same attributes as
SetCtrlAttribute ?!?
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 1 of 4
(3,153 Views)
I don't often find bugs in CVI, but I think I just found another one:
PromptPopup() does not have a description of its return value (neither in
the fp, in the help file or even online:
http://zone.ni.com/reference/en-XX/help/370051K-01/cvi/cvipromptpopup/ )
Apparently 0 means [OK] has been pressed and [1] if [Esc] has been pressed.
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 2 of 4
(3,151 Views)

Hi Guillaume,

 

You're right about the missing help in PromptPopup. That was a bug that was fixed in 9.0.

 

As for the SetAttributeForCtrls function, it's not so much a bug as a limitation. The function does not handle non-integer attributes, and its help does state this . If you look at the implementation of the function (C:\Program Files\National Instruments\CVIxx\toolslib\toolbox.c) you'll find that it's a very simple implementation that does not handle attributes individually. Since 90% or so of attributes are integers, I guess someone still deemed sufficiently useful to include in the Programmer's Toolbox.

 

For now, you can still use it for the callback pointer by simply casting the pointer to an integer when you pass it to the function. But this relies on the knowledge that a pointer is a 4-byte quantity. If you ever decide that you need to build a 64-bit version of your program, then making that cast will be incorrect, and you will get a compiler warning to that effect.

 

Luis

0 Kudos
Message 3 of 4
(3,125 Views)
Thanks for the answer, I suspected as much.
It wouldn't be too hard to rewrite SetAttributeForCtrls() to accept any
argument type... Just a bit tedious.
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 4 of 4
(3,111 Views)