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 - menu to return activate a menu with alternate selection http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 menu to return      Activate a menu with alternate selection
------------------------------------------------------------------------------
 Syntax
   menu to uVar [on select do xProc] return

 Arguments
   uVar is a uint variable receiving the menu selection.
   xProc is a procedure to execute while navigating the menu.

 Description
   The menu to return command performs similarly to the menu to command
   with the following differences.

   The menu system is initiated at a menu selection defined by uVar rather
   than the first @ prompt. The menu to return command returns on
   every keystroke that does not move the highlight bar to a new selection.

   Only cursor movement in the orientation of the menu moves the menu bar.
   For example, if the menu is oriented horizontally the right and left
   cursor keys move the cursor bar, and up and down cursor keys exit the
   menu.

   Any key not related to cursor movement terminates the command with
   uVar containing the id of the current selection. Used with
   lastkey(), the menu to return command can be used to create complex
   menuing systems with context-sensitive help.

   The uVar variable must contain the starting id value for the
   menu selection when menu to return is invoked. If uVar is out
   of range, it is set to the first valid id within the @ prompt
   menu.

   The clear menu command must be called after menu to return because the
   state of @ prompt is always saved.

 Example
   #define EXAMPLE_MENU
   #include example.hdr

   /*
   Use the return keyword, so you can process up and down cursor keys while
   menu to processes left and right cursor keys.
   */
   
   proc Test_menutoreturn
   vardef
       uint uChoice
   enddef
   clear
   cursor( .f. )
   set message to 1
   @ 0,  0  prompt "Edit"   message "Edit a record"
   @ 0, 10  prompt "Goto"   message "Go to a record"
   @ 0, 20  prompt "Delete" message "Delete a record"
   @ 0, 30  prompt "Quit"   message "Return to DOS"
   menu to uChoice return
   do case
   case lastkey() == K_ENTER
      do case
      case uChoice == 1
         @ 5, 0 ?? "Edit was selected."
      case uChoice == 2
         @ 5, 0 ?? "Goto was selected."
      case uChoice == 3
         @ 5, 0 ?? "Delete was selected. "
      case uChoice == 4
         @ 5, 0 ?? "Quit was selected. "
      endcase
   case lastkey() == K_ESC
      @ 5, 0 ?? "Selection cancelled, choice was", istr( uChoice )
   otherwise
      ? "Code of pressed key:", istr( lastkey() )
   endcase
   clear menu // otherwise subsequent prompts would be added to this menu
   wait
   endproc

   proc main
   Test_menutoreturn()
   endproc

See Also: menu to

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