CompuServe Thread

Forum unknown · Modula-2

#IDCMP Events

11 messages in this thread
#117345From: Art SteinmetzApr 3, 1988 10:53 PM
This query applies to Benchmark but I assume is general Intuition topic. The line below is a typical for a loop which processes Intuition messages: MsgPtr := GetMsg(wp^.UserPort^); I have seen examples of code where MstPtr is of type IntuiMessagePtr (from Intuition) AND of type MessagePtr (from Ports). What gives? The record each of these types point to is vastly different. What determines what GetMsg returns? I changed a simple "Wait for CloseWindow event" program to conform to both types and both worked. It seems as if I can arbitrarily access either record type depending on the declaration of the pointer at the outset. Is that true? Thanks. — Art
#117362From: Scott BallantyneApr 4, 1988 12:41 AM
Well, GetMsg() will return whatever (if any) messages are currently posted to the particular port you are GetMsg'ing. At an intuition port, such as you show in your message, you will get IntuiMessages, at other ports, you might well be getting DosPackets, or ZombieMessages (if you are an ARP user), or custom messages of your own design. If your simple close window program didn't peer inside the record contents, and only Reply'ed the message and then closed the window, that's why it worked. If you need more info, then you should declare it as an IntuiMessage(), in this case. I suppose you could declare GetMsg() as returning a pointer to a variant record, if they have those in M2, I am the world's biggest disliker of pascal and it's descendents, so I'll have to bow out here. Hope this was of some help,
#117362From: Scott BallantyneApr 4, 1988 12:41 AM
Well, GetMsg() will return whatever (if any) messages are currently posted to the particular port you are GetMsg'ing. At an intuition port, such as you show in your message, you will get IntuiMessages, at other ports, you might well be getting DosPackets, or ZombieMessages (if you are an ARP user), or custom messages of your own design. If your simple close window program didn't peer inside the record contents, and only Reply'ed the message and then closed the window, that's why it worked. If you need more info, then you should declare it as an IntuiMessage(), in this case. I suppose you could declare GetMsg() as returning a pointer to a variant record, if they have those in M2, I am the world's biggest disliker of pascal and it's descendents, so I'll have to bow out here. Hope this was of some help,
#117438From: Vic WagnerApr 4, 1988 10:59 AM
As I recall, IntuitionMessages have Exec Messages as their first component. If you're waiting on an Intuition port, then you'll be getting IntuiMessages.
#117529From: Art SteinmetzApr 5, 1988 8:21 AM
> If you're waiting on an Intuition port, then you'll be getting > IntuiMessages. Not necessarily, it seems. When I declare the Pointer as a MessagePtr (from Ports) I can't access fields in the IntuiMessage structure. The compiler flags an error – as you would expect. Simply changing the pointer TYPE to IntuiMessagePtr fixes this. Conversely, as a MessagePtr TYPE I can access fields of the Message structure in Ports. I did not have to change the port from UserPort^ in either case. — Art
#117538From: Vic WagnerApr 5, 1988 10:51 AM
Art, that is a function of the language you are using, not the system. IDCMPs only return IntuiMessages.
#117538From: Vic WagnerApr 5, 1988 10:51 AM
Art, that is a function of the language you are using, not the system. IDCMPs only return IntuiMessages.
#117529From: Art SteinmetzApr 5, 1988 8:21 AM
> If you're waiting on an Intuition port, then you'll be getting > IntuiMessages. Not necessarily, it seems. When I declare the Pointer as a MessagePtr (from Ports) I can't access fields in the IntuiMessage structure. The compiler flags an error – as you would expect. Simply changing the pointer TYPE to IntuiMessagePtr fixes this. Conversely, as a MessagePtr TYPE I can access fields of the Message structure in Ports. I did not have to change the port from UserPort^ in either case. — Art
#117438From: Vic WagnerApr 4, 1988 10:59 AM
As I recall, IntuitionMessages have Exec Messages as their first component. If you're waiting on an Intuition port, then you'll be getting IntuiMessages.
#117580From: Steve FaiwiszewskiApr 5, 1988 8:11 PM
GetMsg() actually returns an address. Since all pointers are compatible with ADDRESS ('cause that's what they really are anyway), MsgPtr := GetMsg(…. MsgPtr can be declared to be any type of pointer you'd like. However, when dealing with intuition, you would want to declare it as IntuiMsgPtr to make sure the compiler will let you access all the right fields that are in the IntuiMessage record pointed to by MsgPtr. When dealing with other kinds of messages, you would – of course – want to declare MsgPtr as a pointer to the appropriate record. – Steve –
#117580From: Steve FaiwiszewskiApr 5, 1988 8:11 PM
GetMsg() actually returns an address. Since all pointers are compatible with ADDRESS ('cause that's what they really are anyway), MsgPtr := GetMsg(…. MsgPtr can be declared to be any type of pointer you'd like. However, when dealing with intuition, you would want to declare it as IntuiMsgPtr to make sure the compiler will let you access all the right fields that are in the IntuiMessage record pointed to by MsgPtr. When dealing with other kinds of messages, you would – of course – want to declare MsgPtr as a pointer to the appropriate record. – Steve –