07-18-2011 08:27 AM
Hi,
I have a numeric control. The type is unsigned int(0- 4 294 967 295). I try to get the value in an unsigned int variable with GetCtrlVal() but when the value is upper than 2 147 483 647, the value is negative. There is a mismatch between the two types. I tried to use unsigned long int, same problem.
Somebody already had this problem? Or somebody know how I can solve my problem.
Thanks everyone.
07-19-2011 05:07 AM
Hi,
I tried to reproduce what you have described but could not succeed in observing the same behaviour.
If I set the control type as unsgined int and pass an unsigned int variable to GetCtrlVal function, it works as expected.
If you see a negative sign that means the variable is signed, so be sure you pass the correct variables.
07-19-2011 06:22 AM
Maybe the problem happens in my version. I'm using Labwindows/CVI 8.1.1
I checked my variables, they are Unsigned int, and when I display the value (printf), I have the negative one. I can do what I want even with this problem, but it's embarrassing.
Thanks for your help and your time.
07-19-2011 06:37 AM
are you sure that you use the correct format specifier in printf?
07-19-2011 06:55 AM
wooooowwwwww!!! So many years I program in C code, and I discover %u to display an unsigned int. :s
I am so sorry. Thanks a lot for your help. I ashamed, but you are very helpful. 😄
07-19-2011 07:07 AM
don't worry, it happens
07-19-2011 08:59 AM - edited 07-19-2011 09:01 AM
Johandball,
Something like this might help you with format types 😉
http://msdn.microsoft.com/en-us/library/75w45ekt(v=vs.80).aspx
Regards,
Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.