Article View: comp.sys.amiga.tech
Article #12156Programming multiple Menu Selections
From: William J. Murphy
Date: Sun, 09 Apr 1989 22:02
Date: Sun, 09 Apr 1989 22:02
36 lines
1691 bytes
1691 bytes
I have been trying to figure out why I have a bug in a program of mine
which uses/supports multiple menu selections. I have 2 menus, one with one
item, the other with two items. The FIRST time that I select Menu1 Item1,or
Menu2 Item2,
I get locked into a loop with number = 0. The FIRST time that I select Menu2
Item1, everything from then on works fine.
I have isolated the problem as what is being returned by the function
number = ItemAddress(main_menu[0], number)->NextSelect;
number is intially given a value from
message = (struct IntuiMessage *)GetMsg(window->UserPort);
class = message->Class;
code = message->Code;
switch(class)
{
case MENUPICK:
handle_main_menu(code);
break;
}
handle_main_menu(number)
From what I have discerned from Mortimore, if number is not a valid
menuNumber then ItemAddress will return a NULL. Is it correct to trap
for this potential error condition? Maybe something like this?
if ((number = ItemAddress(main_menu[0], number)-NextSelect) == NULL)
number = MENUNULL;
I use (number != MENUNULL) as a conditional test in a while loop.
Finally, I guess I am asking how do others support multiple menu selections
and is what I am doing flawed.
Bill Murphy
Technical Details
Message-ID:
<2124@pur-phy>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!mentor.cc.purdue.edu!j.cc.purdue.edu!pur-ee!pur-phy!murphyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!mentor.cc.purdue.edu!j.cc.purdue.edu!pur-ee!pur-phy!murphy From: murphy@pur-phy (William J. Murphy) Newsgroups: comp.sys.amiga.tech Subject: Programming multiple Menu Selections Message-ID: <2124@pur-phy> Date: 9 Apr 89 22:02:13 GMT Reply-To: murphy@newton.physics.purdue.edu (William J. Murphy) Organization: Purdue Univ. Physics Dept., W. Lafayette, IN Lines: 36