Yes, I see there is some basic understanding missing. Pointers and casts are fundamental concepts and IMO should be understood before attempting any kind of C or C++ coding project. Understanding the fundamentals will resolve so many future frustrations.
Regarding pointers, this is an unfortunate example for you to use to make sense of pointers, since in this particular case, the pointer is not actually being used as a pointer. A pointer is nominally a 32 bit value. If used as a pointer, then it is a 32 bit address in memory (thus, a pointer). If not used as a pointer, then it is simply a 32 bit number. The notification structure has a pointer (a 32 bit number) called notifyDetailsP that usually contains an actual pointer to user data of some kind in memory. However, if the user data fits in a 32 bit value, it can simply be passed in the pointer, instead of putting it someplace else in memory and then pointing to it. For example, a value of 64 can mean 64 balloons, or it could mean the 64th byte in memory. The first is a common count, a number to be used in arithmetic. The second is a reference to a location in memory. Both are simply the value 64. The compiler must know how you mean to have the value 64 used. There are several ways to inform the compiler how you want a value to be used. The most common is to give the value a type, such as 'int' or '*'. The compiler uses the value according to the type given it. An 'int' or integer is used for common arithmetic. A '*' or pointer to something will be used as a memory address. Another way to inform the compiler is to use a cast. A cast is simply telling the compiler how you want a value to be used in a particular situation. If I have given a value the type of pointer, but want to use it as an integer, I would use a cast like: "char * p; int x; x = (int)p; p = (char*)x;". It doesn't change the value, it just tells the compiler to use it in a different way. Regarding HEX and DECIMAL, these are simply different ways of representing a numerical value. The decimal number 16 is the same as the hex (hexidecimal) number 10, and to tell the compiler we mean 10 in hex, we preceed it with 0x to make 0x10. Some values are easier to comprehend in decimal, the representation most common for counting. Other values are better understood in hexidecimal, since hex naturally divides the value in to convenient 4 bit pieces. I'm getting long winded, so if any of this is unclear, there are countless tutorials on the web. Send email if you need help with sample code. Jeff On Fri, Aug 1, 2008 at 7:33 AM, Christopher Stamper <[EMAIL PROTECTED]> wrote: > On Thu, Jul 31, 2008 at 8:59 PM, Jeff Loucks <[EMAIL PROTECTED]> wrote: >> >> Except that notifyDetailsP isn't a pointer in this case. It is the >> value itself. Do the following: >> >> UInt16 device = (UInt16)(((SysNotifyParamType*)cmdPBP)->notifyDetailsP); >> >> If you have any question about the use of notifyDetailsP, display the >> value of notifyDetailsP from the notification handler and see if it is >> a pointer, or the value itself. I found it to be the actual value, not >> a pointer to the value. > > Ok, that looks good. I never really understood much about pointers and > casts... :-( > > So, IF that works, then I still have the 'problem' of two notifications. I > haven't found this to be the case yet, but maybe they are being missed. The > problem I see here would be that the first notification may be the power, > thus getting ignored. The second may be the serial/usb, and may get > missed... ? > > Also, I don't exactly know what to do with the hex (?) values. Can I just if > (device == 0x0010) or should I convert it to decimal somehow? Or is it dec? > Sorry for my total ignorance... > > Well, I'll see what happens.. > > > Thanks a lot! > > > -- > Christopher Stamper > > Email: [EMAIL PROTECTED] > Web: http://tinyurl.com/2ooncg > gTalk: http://tinyurl.com/6e359r > Skype: cdstamper > > -- > For information on using the ACCESS Developer Forums, or to unsubscribe, > please see http://www.access-company.com/developers/forums/ -- [Jeff Loucks, Gig Harbor, WA, USA] -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
