Re: Table-driven ring menus
Posted in 1997
MIS Dept wrote: > > We're modifying our menu structure for our homegrown Informix code. Instead of creating > a ring menu with all various front-end programs linked into a single executable, we're > looking to split out the various front-ends into separate executables, then create a > table-driven menu structure. While we can make a 'drop down' style menu relatively > easy, we would like to keep the ring menu structure for our user community. Any way to > create a table-driven ring menu? I figure that someone may have already asked this > question, but I could find no reference in the newsgroup archive. Here's a kludge to accomplish this: 1) Initialize arrays of strings for menu choices and prompts to NULL. 2) In the code, physically before executing the menu statement, fetch the actual choices and prompts into the array. 3) Create a menu with the maximum number of items possible using an array of variables for the choice and prompt strings for all. In the code for BEFORE MENU clause test if the choice for each array element corresponding to the menu item is NULL, if NULL execute HIDE OPTION choice[n] otherwise execute SHOW OPTION choice[n]. 4) The command for each choice (except any fixed choices like EXIT) would be a call to a function, passing the choice number or name, which would execute the appropriate code based on the argument(s) passed to it. This function could be written in 4GL with a big case statement or "C" using an array of function names or id#s and function pointers. You get the picture. The only rub is the phrase "maximum possible number of choices" this may be hard to determine at coding time. Art S. Kagel