walther@econ.vu.nl (Walther Schoonenberg/10000) (01/28/91)
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. Greetings, Walther ============================================================================== Walther Schoonenberg Vakgroep Econometrie Faculteit der Econonomische Wetenschappen en Econometrie * * * * * Vrije Universiteit * * * * De Boelelaan 1105 * * * * * 1081 HV Amsterdam * * * * The Netherlands * * * * * (020) 5483609 walther@econ.vu.nl ==============================================================================
ecc_jim@ecc.tased.oz.au (01/31/91)
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