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 - menugetprompt() return a prompt's text http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 menugetprompt()     Return a prompt's text
------------------------------------------------------------------------------
 Declaration
   menu.hdr

 Syntax
   func char menugetprompt extern
   param value _MENU pMenu, ;
         value int   iId

 Arguments
   pMenu is the pointer to a previously created menu system. If 0, the
         default menu will be used.
   iId   is the id number of the prompt.

 Return
   The text (caption) of the specified prompt, including the hot key marker
   (&), or an empty string in case an invalid menu pointer or id was passed.

 Description
   This is a utility function that might be called from within menu handlers.

 Example
   #define EXAMPLE_MENU
   #include example.hdr

   proc Test_menugetprompt
   vardef
      _MENU pMenu
      uint  uKey, uId, uPos
      char  cPrompt
      byte  aPrompt[ 256 ] based cPrompt
   enddef
   
   cursor( .f. )
   clear
   
   pMenu := menunew()
   
   menupromptnew( pMenu, 2, 10, " Option 1   ", 1, .t., .t. )
   menupromptnew( pMenu, 3, 10, " Option 2   ", 2, .t., .t. )
   menupromptnew( pMenu, 4, 10, " Option 3   ", 3, .t., .t. )
   menupromptnew( pMenu, 5, 10, " Option 4   ", 4, .t., .t. )
   
   @ 8, 10 ?? "Press Up/Down to navigate, Enter to toggle mark, Esc to quit"
   
   do while .t.
   
      uKey := getkey()
   
      do case
      case uKey == K_DOWN
         if .not. menusetnext( pMenu )
            menusetfirst( pMenu )
         endif
      case uKey == K_UP
         if .not. menusetprev( pMenu )
            menusetlast( pMenu )
         endif
      case uKey == K_ENTER
         uId     := menucurrentid( pMenu )
         cPrompt := menugetprompt( pMenu, uId )
         uPos    := len( cPrompt ) - 2
         if aPrompt[ uPos ] == '.'
            aPrompt[ uPos ] := ' '
         else
            aPrompt[ uPos ] := '.'
         endif
         menusetprompt( pMenu, uId, cPrompt, .t. )
      case uKey == K_ESC
         exit
      endcase
   
   enddo
   
   menuclear( pMenu )
   cursor( .t. )
   clear
   
   endproc

   proc main
   Test_menugetprompt()
   endproc

See Also: menugetpromptlen() menusetprompt()

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