ON BAR Command Example

The following example demonstrates a system of cascading submenus. A menu bar named mnuDinner is created with two menu bar titles. Each title uses ON PAD to activate the menu named popMainCourse or popDessert. The menus named popMainCourse and popDessert each have additional menus named popBurger, popPizza and popPie assigned to their item lists with three ON BAR commands. The popOlives and popPie items have additional menus assigned with two ON BAR commands.

When you make a selection, ON SELECTION POPUP ALL executes a procedure named yourchoice that activates a window and displays your choice. The choice is determined with POPUP( ) and PROMPT( ), which return the name of the menu and the contents (text) of the menu item.

DEFINE WINDOW wOrder FROM 10,0 TO 13,39
DEFINE MENU mnuDinner
DEFINE PAD padOne OF mnuDinner PROMPT '\<Main Course' KEY ALT+M, ''
DEFINE PAD padTwo OF mnuDinner PROMPT '\<Dessert'   KEY ALT+D, ''
ON PAD padOne OF mnuDinner ACTIVATE POPUP popMainCourse
ON PAD padTwo OF mnuDinner ACTIVATE POPUP dessert
DEFINE POPUP popMainCourse MARGIN MESSAGE ;
   'We have burgers and pizza today'
DEFINE BAR 1 OF popMainCourse PROMPT '\<Hamburgers'
DEFINE BAR 2 OF popMainCourse PROMPT '\<Pizza'
ON BAR 1 OF popMainCourse ACTIVATE POPUP burger 
ON BAR 2 OF popMainCourse ACTIVATE POPUP pizza 
DEFINE POPUP burger MARGIN MESSAGE ;
   'What would you like on your burger?'
DEFINE BAR 1 OF burger PROMPT '\<Ketchup'
DEFINE BAR 2 OF burger PROMPT '\<Mustard'
DEFINE BAR 3 OF burger PROMPT '\<Onions'
DEFINE BAR 4 OF burger PROMPT '\<Pickles'
DEFINE POPUP pizza MARGIN MESSAGE ;
   'Here are the available toppings'
DEFINE BAR 1 OF pizza PROMPT '\<Anchovies'
DEFINE BAR 2 OF pizza PROMPT '\<Green Peppers'
DEFINE BAR 3 OF pizza PROMPT '\<Olives'
DEFINE BAR 4 OF pizza PROMPT '\<Pepperoni'
ON BAR 3 OF pizza ACTIVATE POPUP olives 
DEFINE POPUP olives MARGIN
DEFINE BAR 1 OF olives PROMPT '\<Black' MESSAGE 'Black olives?'
DEFINE BAR 2 OF olives PROMPT '\<Green' MESSAGE 'Green olives?'
DEFINE POPUP dessert MARGIN MESSAGE 'Our dessert offerings'
DEFINE BAR 1 OF dessert PROMPT '\<Brownies'
DEFINE BAR 2 OF dessert PROMPT '\<Cookies'
DEFINE BAR 3 OF dessert PROMPT '\<Ice Cream'
DEFINE BAR 4 OF dessert PROMPT '\<Pie'
ON BAR 4 OF dessert ACTIVATE POPUP pie 
DEFINE POPUP pie MARGIN MESSAGE 'What kind of pie?'
DEFINE BAR 1 OF pie PROMPT '\<Blueberry'
DEFINE BAR 2 OF pie PROMPT '\<Cherry'
DEFINE BAR 3 OF pie PROMPT '\<Peach'
DEFINE BAR 4 OF pie PROMPT '\<Rhubarb'
ON SELECTION POPUP ALL DO yourchoice
ACTIVATE MENU mnuDinner
PROCEDURE yourchoice
ACTIVATE WINDOW wOrder 
CLEAR
DO CASE
   CASE POPUP( ) = 'BURGER'
      @ 0,0 SAY 'A ' + POPUP( ) + ' order:'
      @ 1,0 SAY 'You ordered a burger with ' + LOWER(PROMPT( ))
   CASE POPUP( ) = 'PIZZA'
      @ 0,0 SAY 'A ' + POPUP( ) + ' order:'
      @ 1,0 SAY 'You ordered a pizza with ' + LOWER(PROMPT( ))
   CASE POPUP( ) = 'OLIVES'
      @ 0,0 SAY 'A ' + POPUP( ) + ' order:'
      @ 1,0 SAY 'You ordered a pizza with ' ;
         + LOWER(PROMPT( )) + ' olives'
   CASE POPUP( ) = 'DESSERT'
      @ 0,0 SAY 'A ' + POPUP( ) + ' order:'
      @ 1,0 SAY 'You ordered ' + LOWER(PROMPT( )) + ' for dessert'
   CASE POPUP( ) = 'PIE'
      @ 0,0 SAY 'A ' + POPUP( ) + ' order:'
      @ 1,0 SAY 'You ordered ' + LOWER(PROMPT( )) + ' pie'
ENDCASE
WAIT WINDOW
DEACTIVATE WINDOW wOrder
RETURN