Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!diemen!ecc.tased.oz.au!ecc_jim From: ecc_jim@ecc.tased.oz.au Newsgroups: comp.sys.acorn Subject: Re: How to create menus in C Message-ID: <1991Jan31.091559.238@ecc.tased.oz.au> Date: 30 Jan 91 23:15:59 GMT References: <740@.econ.vu.nl> Lines: 59 In article <740@.econ.vu.nl>, walther@econ.vu.nl (Walther Schoonenberg/10000) writes: > > Hello all of you, > > I've got a little RISCOS_LIB C problem. I don't know how to make a > nested menu structure in C. If you do, for instance, the following: > > menu temp[5]; > > temp[0] = menu_new("Main menu",">Info,Why,Quit"); > temp[1] = menu_new("Why","Can't,I,Do,This?"); > menu_submenu(temp[0],2,temp[1]); > temp[2] = menu_new("I","Do,This?"); > menu_submenu(temp[1],2,temp[2]); > temp[3] = menu_new("Do","This?"); > menu_submenu(temp[1],3,temp[3]); > > return temp[0]; > > In this example I want to create this menu structure: > > > Main Menu first level second level > --------- > Info -> InfoProg box > Why -> Why > Quit --- > Can't > I -> I > -- > Do > This? > Do -> Do > This? -- > This? > > > This doesn't work. The temp[[3] submenu disappears completely, without > any warning or error message. Why? Maybe this is not a 'strict hierarchy' > about which the manual talks. But what is a strict hierarchy exactly and > if it is not possible to use menu_submenu to create the above menu > structure, how could you make such a menu structure ? > > Any help greatly appreciated. > > Walther Schoonenberg From the small piece of code that you have submitted, I am guessing that you have placed all the above in a function - including the declaration of temp. This means the local array temp[5] is being returned to the free memory pool at the end of the function with only the value of temp[0] being passed back to the calling function. Try making all your menu handles reside in static variables. Jim Palfreyman Elizabeth Computer Centre, Tasmania, Australia e-mail: ecc_jim@ecc.tased.oz.au