[comp.sys.mac.programmer] GetMenu danger??

DN5@PSUVM.BITNET (12/19/89)

Hi,

I am writing a HyperCard XCMD to use popup menus from resources
(I didn't like the idea of creating the data structures each and
every time I invoked the thing).  I pass the menu id to the XCMD,
and then I do a GetMenu on the id, then go through that menu looking
for submenus, and call GetMenu on them.

This works (so far), and it returns the proper values.  After I use the
menus, I call DeleteMenu on them (also recursively) to take them out
of the list of active menus.

After I am finished with the menus, I make them purgeable again, then
return.

My problem:

In Inside Mac I, it claims that GetMenu should never be called more than
once for a menu.  Yet I have to call GetMenu each time I invoke this
XCMD; however, I do a DeleteMenu for each menu I call GetMenu for.

My question:

Even though this SEEMS to be working, am I creating a time bomb?

                           Thanks,
                             D. Jay Newman
                             dn5@psuvm.psu.edu

ps.
  Please use email for replies, because Thursday I am going away for
a week (University Christmas).

6500stom@hub.UUCP (12/21/89)

From article <89353.093306DN5@PSUVM.BITNET>, by DN5@PSUVM.BITNET:
> I am writing a HyperCard XCMD to use popup menus from resources
> (I didn't like the idea of creating the data structures each and
> every time I invoked the thing).  I pass the menu id to the XCMD,
> and then I do a GetMenu on the id, then go through that menu looking
> for submenus, and call GetMenu on them.
>
> In Inside Mac I, it claims that GetMenu should never be called more than
> once for a menu.  Yet I have to call GetMenu each time I invoke this
> XCMD; however, I do a DeleteMenu for each menu I call GetMenu for.

"(For menus read from a resource file with GetMenu, use ...Release-
Resource instead [of DisposeMenu]" (I-352) Which means that if you
want to torch a menu from the menu bar and memory you have to first
DeleteMenu and then ReleaseResource (in your case).

The Menu Mgr is usually pretty flexible but I couldn't get Get/Set-
ItemCmd to work for me using normal command keys. I suspect they only
work for hier-menus but maybe I'm holucinating. I found a work around
anyway (no need to reply).

/            Josh Pritikin             T Ignorance is bliss.           \
| Internet:  6500stom@ucsbuxa.ucsb.edu | I must be in hell.            |
| AppleLink: Josh.P                    | My room is proof that entropi |
\ GEnie:     J.Pritikin                ! exists.                       /