home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / gt_askus.prg < prev    next >
Text File  |  1993-10-14  |  2KB  |  104 lines

  1. /*
  2.     File......: GT_AskUser.prg
  3.     Author....: Martin Bryant
  4.     BBS.......: The Dark Knight Returns
  5.     Net/Node..: 050/069
  6.     User Name.: Martin Bryant
  7.     Date......: 04/02/93
  8.     Revision..: 1.0
  9.  
  10.     This is an original work by Martin Bryant and is placed
  11.     in the public domain.
  12.  
  13.     Modification history:
  14.     ---------------------
  15.  
  16.     Rev 1.0 04/02/93
  17.     PD Revision.
  18. */
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *      GT_ASKUSER()
  23.  *  $CATEGORY$
  24.  *      Video
  25.  *  $ONELINER$
  26.  *      Ask the user a question
  27.  *  $SYNTAX$
  28.  *      GT_AskUser(<cMessage>,<aKeys>,[<cTitle>], ;
  29.  *                 [<cColour>],[<cBox>],[<nTop>],[<nLeft>], ;
  30.  *                 [<nBottom>],[<nRight>],[<nSeconds>]) ;
  31.  *      -> nResponce
  32.  *  $ARGUMENTS$
  33.  *      <cMessage> is the message to display.
  34.  *
  35.  *      <aKeys> is an array of legal INKEY() values
  36.  *
  37.  *      <cTitle> is an optional title.
  38.  *
  39.  *      <cColour> is an optional colour string.
  40.  *
  41.  *      <cBox> are optional box lines.
  42.  *
  43.  *      <nTop>,<nLeft>,<nBottom> and <nRight> fix the position
  44.  *      of the window.
  45.  *
  46.  *      <nSeconds> is the time to wait for a responce.
  47.  *  $RETURNS$
  48.  *      nResponce
  49.  *  $DESCRIPTION$
  50.  *      To display a message, ask the user a question, wait
  51.  *      for a responce and restore the screen.
  52.  *  $EXAMPLES$
  53.  *  $SEEALSO$
  54.  *
  55.  *  $INCLUDE$
  56.  *
  57.  *  $END$
  58.  */
  59.  
  60. #include "GT_LIB.ch"
  61.  
  62. FUNCTION GT_AskUser(cMessage,aKeys,cTitle,cColour,cBox,nTop, ;
  63.     nLeft,nBottom,nRight,nSeconds)
  64.  
  65. LOCAL cScreen := SAVESCREEN(00,00,MAXROW(),MAXCOL())
  66. LOCAL nKey := 0
  67. LOCAL nCursor := GT_NoCursor()
  68.  
  69. Default cMessage to 'Yes or No ?'
  70. Default aKeys to {ASC('N'),ASC('Y'),ASC('n'),ASC('y')}
  71. Default cTitle to ''
  72. Default cColour to SETCOLOR()
  73. Default cBox to BOX_SS
  74. Default nTop to -1
  75. Default nLeft to -1
  76. Default nBottom to -1
  77. Default nRight to -1
  78. Default nSeconds to 120
  79.  
  80. //  Message
  81. GT_Message(cMessage,cTitle,cColour,cBox,nTop,nLeft, ;
  82.     nBottom,nRight)
  83.  
  84. DO WHILE (ASCAN(aKeys,nKey) = 0)
  85.  
  86.     // Wait for key press
  87.     nKey := INKEY(nSeconds)
  88.  
  89.     IF nKey = 0
  90.         nKey := aKeys[1]
  91.     ENDIF
  92.  
  93. ENDDO
  94.  
  95. //  Reset
  96. RESTSCREEN(00,00,MAXROW(),MAXCOL(),cScreen)
  97. SETCURSOR(nCursor)
  98.  
  99. /*
  100.     End of GT_AskUser()
  101. */
  102. RETURN(nKey)
  103.  
  104.