LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Get all attributes ?

Hello all,
is there a simple way to dump all the values of the attributes of a control,
as a debugging aid ?
Some way to iterate on all the valid attributes of a given control ?

Something like:
GetCtrlAttribute(Pnl, Ctrl, ATTR_..., &Something); printf("ATTR_...:
%d/s/f", Something)
But on all of them...

Of course that function would need to know the name of a given attribute and
its numeric/string type.

I could probably get the list of all ATTR_... from the userint.h file and
check the type manually for each, do the Get and ignore errors.
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 1 of 8
(4,230 Views)

A "simple" way to do this would be welcome! Smiley Wink

But considering that there are more or less 50 control types with more than 600 attributes (that do not apply to each of them, of course!) you see that this is not a trivial task...

 

You can see the attributes that actually apply to each control type by right-clicking on it and selecting "Control help" in the context menu: selecting "Control attributes" in the menu page you'll see a list of all and only the attributes that apply to a given control type. Consider that most controls have different type but can actually be considered almost the same (e.g. almost all numerics share the same attributes).

 

A sample of what could be obtained can be found by saving a UIR in text format (.TUI): if you are interested in the state of a control at design time this can be enough for you, otherwise you must look for single attributes ad runtime as you already have imagined.



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 2 of 8
(4,222 Views)
In the process of implementing it to verify a strange bug, I think I
stumbled upon another few bugs...

Doing GetPanelAttribute or GetCtrlAttribute with an attribute which is
undefined for that type of control or panel should return a non-zero value
and trigger an optional library error, right ?


Well, I get all kind of weird stuff:
GetPanelAttribute(Pnl, ATTR_LABEL_TEXT, Str)
gives a general protection fault. Yes, I know a panel has no label, but IMO
it shouldn't crash.

GetCtrlAttribute(Pnl, StripChart, ATTR_TOOLTIP_TEXT, Str)
gives a FATAL RUN-TIME ERROR: Invalid argument type: found 'pointer to
char', expected 'pointer to int'.

GetCtrlAttribute(..., ATTR_HORIZONTAL_BAR_VALUE, &Double)
gives FATAL RUN-TIME ERROR Invalid argument type: found 'pointer to double',
expected 'pointer to int'. Maybe it's just the specification comment in
userint.h which is wrong


Will post more on that later.
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 3 of 8
(4,213 Views)

Hi Guillaume,

 

I could reproduce the GPF in the function call status = GetPanelAttribute ( panel_handle, ATTR_LABEL_TEXT, text );

 

I guess NI will be happy to hear about it Smiley Very Happy

0 Kudos
Message 4 of 8
(4,211 Views)

You'll get fatal runtime errors when you a pass a pointer to the wrong kind of parameter type to the get attribute functions.  What's probably happening is that you're effectively getting a buffer overrun when you pass a pointer to a 32-bit int and the function writes a 64-bit double to the pointer.  My first thought was to always pass something with 64 bits, but since some of the functions are expecting a char array, you might have to do is something like this:

 

unsigned char buffer[1000];

...

GetCtrlAttribute(panel, control, i++, (void *)buffer);

...

 

and then parse the contents of the buffer appropiately. 

 

Edit:  Though that still won't explain some of the stuff you're seeing. 

 

0 Kudos
Message 5 of 8
(4,210 Views)

Your first example is definitely a bug (filed as bug #345074). The crash is happening in the compiler-generated user protection code, before the GetPanelAttribute library function has a chance to validate whether the attribute passed is valid for this function. However, you are correct. It should not crash and this will be fixed.

 

The other two examples are both manifestations of the same issue: the user protection code is (incorrectly) assuming that any attribute that is not part of a known set of non-integer attributes must be an integer attribute. For example, if you called:

 

   GetCtrlAttribute (panel, control, 12345678, str)

 

you'd see the same error message.

 

Although this is also arguably a bug, since the message that the user protection code reports is not really pertinent, NI will probably not fix it, since the alternative would be to slow down all the user protection checks a bit, and that's not a worthwhile tradeoff for something that doesn't have that negative of an impact (if you changed your variable's data type to int, as a result of this error, you'd then receive the correct "attribute not valid" error).

 

Luis

0 Kudos
Message 6 of 8
(4,201 Views)
Thanks LuisG & Co,
I seem to be finding a lot of bugs in CVI lately... 😉


Here's the code I used to dump all attributes from a panel/control, it can
come in handy when debugging strange user interface problems:

http://www.gdargaud.net/Hack/LabWindows.html#ShowAttr

But be warned that it's likely to cause buffer overflows when getting string
attributes. Strictly for debug.
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 7 of 8
(4,192 Views)

This bug has been fixed in CVI2012 Smiley Happy

0 Kudos
Message 8 of 8
(4,142 Views)