03-21-2012 12:40 PM
03-22-2012 04:31 AM
A "simple" way to do this would be welcome!
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.
03-22-2012 10:10 AM
03-22-2012 10:23 AM
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
03-22-2012 10:23 AM - edited 03-22-2012 10:25 AM
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.
03-22-2012 02:51 PM
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
03-23-2012 06:10 AM
08-13-2012 06:01 AM
This bug has been fixed in CVI2012