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 - menusetprompt() change the text of a prompt http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 menusetprompt()     Change the text of a prompt
------------------------------------------------------------------------------
 Declaration
   menu.hdr

 Syntax
   func logical menusetprompt extern
   param value _MENU   pMenu, ;
         value int     iId, ;
         const char    cPrompt, ;
         value logical lShow

 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.
   cPrompt is the new prompt text.
   lShow   controls if the prompt shall be re-displayed.

 Return
   A logical indicating the success of this function. If .t., the prompt
   could be assigned, if .f., an invalid menu pointer was specified.

 Description
   This function assigns a new prompt text to a menu item. It can be used to
   dynamically change prompt texts at run-time, dependung on certain results
   or conditions. The new prompt text is passed in the cPrompt argument.
   If .t. is passed in the lShow argument, the item will be automatically
   re-displayed with the new text.

 Example
   #define EXAMPLE_MENU
   #include example.hdr

   proc Test_menusetprompt
   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 marking, 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_menusetprompt()
   endproc

See Also: menugetprompt() menusetmessage()

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