[comp.sys.apple] GS Menu Item numbering

AWCTTYPA@UIAMVS.BITNET ("David A. Lyons") (02/12/89)

>Date:         Fri, 10 Feb 89 15:43:24 GMT
>From:         Jason Blochowiak <puff!cat28!blochowi@SPEEDY.CS.WISC.EDU>
>Subject:      Re: resources, etc. (GS)
>
>> Not on the GS:  menu items have their own ID numbers, so they don't
>> change when you rearrange your menus.
>
>I believe he was talking about menu ITEMS, not the menus themselves,
>in which case he's correct - to have the menu layout conceptually map
>to the application, you have to "move down" all the item ID #'s when
>you insert a item. Fortunately (sp?) we have "enum" and "x equ y+1"

I didn't see what you were saying at first--I thought you were
denying that GS menu items, as well as the menus themselves, could
have arbitrary numbers.  (They can, and mine do.)

Now, it looks like you prefer to use a menu item number as an index
into a table of addresses of subroutines to call when an item is
selected.  If you take that approach, then you do indeed have to
re-number your menu items _if_ (and only if) you want to have the
table entries in the same order as the menu items.  That is _not_
necessary, but it does make it easier to deal with your source code.

I prefer to just have a big "case" (or "switch" in C) statement that
determines what subroutine to call, and I never renumber my menu
items.

   case itemID of
      OpenItem:  OpenSomething;
      CloseItem: CloseFrontWindow;
      QuitItem:  QuitFlag := true;
      ...
   end;

>    Jason Blochowiak (blochowi@wherever_i_am - garfield.cs.wisc.edu?)
>            "Not your average iconoclast..."

--David A. Lyons              bitnet: awcttypa@uiamvs
  DAL Systems                 CompuServe:  72177,3233
  P.O. Box 287                GEnie mail:    D.LYONS2
  North Liberty, IA 52317     AppleLinkPE: Dave Lyons

blochowi@cat28.CS.WISC.EDU (Jason Blochowiak) (02/15/89)

	I wasn't the original poster - I realize that menu items can have IDs
in whatever sequence the application writer wishes. My point was that
> [...] to have the menu layout conceptually map to the application [...]
	Even if you're not going to use table based calls, it's conceptually
"neater" to have them in sequence. Something like "well, I may not be doing
it now, but it'll make it easier if I decide to." Just a clarification...


 ------------------------------------------------------------------------------
		Jason Blochowiak (blochowi@garfield.cs.wisc.edu)
			"Not your average iconoclast..."
 ------------------------------------------------------------------------------