Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - menunew() create a new menu system http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 menunew()           Create a new menu system
------------------------------------------------------------------------------
 Declaration
   menu.hdr

 Syntax
   func _MENU menunew extern

 Arguments
   None.

 Return
   The pointer to a new menu system, or 0 in case of an error.

 Description
   This function allocates memory for a new menu system, and sets up some
   internal data required for the menu.

   If the function returns 0, the required memory space could not be
   allocated - any other return value is a valid menu pointer that should be
   saved for later use as it is required by almost all other menu functions
   to reference the menu system.

 Example
   #define EXAMPLE_MENU
   #include example.hdr

   proc Test_menunew
   vardef
      _MENU pMenu
      int   iChoice, iTest
      uint  uKey
   enddef
   
   clear
   cursor( .f. )
   
   menuseterror( .f. )
   pMenu = menunew()
   
   if pMenu == 0
      ? "Could not create the menu !"
      quit
   else
      iTest := 0
      iTest += menupromptnew( pMenu, 5, 10, " 1st prompt ", 1, .t., .t. )
      iTest += menupromptnew( pMenu, 6, 10, " 2nd prompt ", 2, .t., .t. )
      iTest += menupromptnew( pMenu, 7, 10, " 3rd prompt ", 3, .t., .t. )
      iTest += menupromptnew( pMenu, 8, 10, " 4th prompt ", 4, .t., .t. )
      if iTest != 10
         ? "Could not create the menu items !"
         quit
      endif
   
      do while .t.
         uKey := getkey()
         do case
         case uKey == K_UP
            menusetprev( pMenu )
         case uKey == K_DOWN
            menusetnext( pMenu )
         case uKey == K_ENTER
            iChoice := menucurrentid( pMenu )
            exit
         case uKey == K_ESC
            iChoice := 0
            exit
         endcase
      enddo
   
      @ 10, 0 ?? "The selection is:", iChoice
      menuclear( pMenu )
   endif
   cursor( .t. )
   
   endproc

   proc main
   Test_menunew()
   endproc

See Also: menuclear()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson