murphy@pur-phy (William J. Murphy) (04/10/89)
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
kevin@uts.amdahl.com (Kevin Clague) (04/10/89)
In article <2124@pur-phy> murphy@newton.physics.purdue.edu (William J. Murphy) writes: > >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) Could this be your problem? ^^^ What you want to do is pass it the addess of your menu chains, not the contents of the first menu item. Otherwise you seem to be on the right track. > 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 I've used the same method with good success. Kevin -- UUCP: kevin@uts.amdahl.com or: {sun,decwrl,hplabs,pyramid,seismo,oliveb}!amdahl!kevin DDD: 408-737-5481 USPS: Amdahl Corp. M/S 249, 1250 E. Arques Av, Sunnyvale, CA 94086 [ Any thoughts or opinions which may or may not have been expressed ] [ herein are my own. They are not necessarily those of my employer. ]
murphy@pur-phy (William J. Murphy) (04/10/89)
In article <2124@pur-phy> murphy@newton.physics.purdue.edu (William J. Murphy) writes: >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; Before I get flamed for the obvious mistake, I will correct it. number = ItemAddress(main_menu[0], number)->NextSelect; if (number == NULL) number = MENUNULL; This seemed to take care of the problem I experienced, but now I am asking myself how do you select multiple menu choices? I tried a few things such as SHIFT-RMB LMB, LMB... In Browser one can multiple select files with SHIFT-LMB, but is multiple selection supposed to be a feature of menus? >Finally, I guess I am asking how do others support multiple menu selections. Bill Murphy
murphy@pur-phy (William J. Murphy) (04/12/89)
In article <172S26aXLs10100WHNE@amdahl.uts.amdahl.com> kevin@amdahl.uts.amdahl.com (Kevin Clague) writes: >In article <2124@pur-phy> murphy@newton.physics.purdue.edu (William J. Murphy) writes: >> >>if ((number = ItemAddress(main_menu[0], number)-NextSelect) == NULL) >Could this be your problem? ^^^ Kevin found my problem, I should be sending an address to the function and not a value. The correct statement is number = ItemAddress( &main_menu[0], number)->NextSelect); if (number == NULL) { number = MENUNULL; } This seems to work fine now. Thanks, Bill Murphy