[comp.sys.mac.programmer] Bug in MPW C v2.0.2 Menus.h file

ron@oscvax.UUCP (Ron Janzen) (07/29/88)

I was recently playing with hierarchical menus on our Mac II running
System Version 5.0 and ran into some problems.  I was trying to attach
an existing hierarchical menu to another menu using the following piece
of code:

SetItemCmd( theMenu, submenuItem, hMenuCmd );
SetItemMark( theMenu, submenuItem, submenuId );

where submenuItem is the item number of the menu entry to which I wanted
to attach the submenu, submenuId is the menu id of the hierarchical menu
that I want to attach there and hMenuCmd is the special command code
defined in "Menus.h" to indicate that this is a hierarchical menu. 

When I did this it did not work.  There was garbage where the command
key equivalents and check marks usually go.  After many different
attempts I finally narrowed it down to the definition of the
SetItemCmd() function in "Menus.h".  This is how they are defined in the
original v2.0.2 "Menus.h":

pascal void GetItemCmd(menu, item, cmdChar)
   MenuHandle menu;
   short item;
   char *cmdChar;
   extern 0xA84E;
pascal void SetItemCmd(menu, item, cmdChar)
   MenuHandle menu;
   short item;
   char cmdChar;
   extern 0xA84F;

I discovered that if cmdChar is defined as a short instead of a char it
works perfectly.  I have therefore changed the definitions of cmdChar in
my version of "Menus.h" to
short *cmdChar;
and
short cmdChar;
respectively. I have a feeling that this may have already been mentioned
in this forum before but just in case it hasn't I thought I would mention
it.
-- 
Ron Janzen
Ontario Science Centre, Toronto
...!{allegra,ihnp4,decvax,pyramid}!utzoo!oscvax!ron