CompuServe Thread

TDI & String Gadgets

6 messages in this thread
#97444From: Mark OlbertDec 9, 1987 12:20 AM
list I'm having problems working with the following TYPE definition from TDI's Modula 2: Gadget = RECORD NextGadget: GadgetPtr; (* next gadget in the list *) LeftEdge, TopEdge: INTEGER; (* "hit box" of gadget *) Width, Height: INTEGER; (* "hit box" of gadget *) Flags: GadgetFlagSet; (* see above *) Activation: ActivationFlagSet;(* see above *) GadgetType: CARDINAL; (* see above *) GadgetRender: ADDRESS; (* pointer to what to render, NULL if nothing *) SelectRender: ADDRESS; (* pointer to highlighted struct *) GadgetText: IntuitionTextPtr; (* text for this gadget *) MutualExclude: LONGINT; (* set bits mean this gadget excludes that gadget, see below *) ******> CASE : INTEGER OF 0: SpecialInfoString: StringInfoPtr; | 1: SpecialInfoProp: PropInfoPtr | 2 : SpecialBoolInfo : BoolInfoPtr ; END; GadgetID: CARDINAL; (* user-definable ID field *) UserData: ADDRESS; (* ptr to general purpose User data (ignored by Intuition) *) END; The '******>' points to where I think my problem is. I can't access any of the possible pointers. It looks to me like the CASE statement is mucked up since no discriminator type (i.e., 'CASE XXX:INTEGER') is declared. Anybody got any ideas? It's kinda hard to use stuff like StringGadgets and what not when you can't get at the related unique info… #?Mark?#
#97616From: Vic WagnerDec 10, 1987 4:27 AM
Mark, The syntax looks fine to me. It ISN'T a case STATEMENT, it's a VARIANT. When you say you can't access the pointers, exactly what did you mean? How did you try? Did the compiler complain?
#97962From: Mark OlbertDec 11, 1987 11:52 PM
Drat, I knew I forgot something! I figured out that it was my problem, not the compiler's…and forgot to remove the message from the board. As long as we're on the subject, though, I thought that VARIANTs had to have a discriminator variable, e.g.,: RECORD CASE xyz: INTEGER OF Var1: Type1| Var2: Type2 END; I don't see the analog to 'xyz' in the Gadget RECORD structure… ?>Mark<? P.S. — 'Var1' and 'Var2' above should be integer values, e.g., '0','1', etc. I screwed up when typing this message, and don't know how to edit it.
#97972From: Michael RiehleDec 12, 1987 12:50 AM
Nope. Variants only need a discriminator TYPE. The tag field (variable) is optional. This was actually a more useful feature in Pascal than it is in Modula-2, but it still has it's place. MCR
#98069From: Vic WagnerDec 12, 1987 6:02 PM
Mark, Nope, you don't need descriminants in records, you can have them if you wish, but they are unneccessary.
#98104From: Steve FaiwiszewskiDec 12, 1987 10:00 PM
You can simply say 'gadget.SpecialInfoString'. – Steve –