home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_OPCONF.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  1.4 KB  |  61 lines

  1. *****************************************************************
  2. FUNCTION OPCONFIRM (echo_on)
  3. *****************************************************************
  4.  
  5. * Wait for operator confirmation in "Y/N" format
  6.  
  7. * Copyright(c) 1991 - James Occhiogrosso
  8.  
  9. #include "set.ch"
  10. #include "inkey.ch"
  11. #include "setcurs.ch"
  12.  
  13. LOCAL keypress, old_cursor
  14.  
  15. * Save entry cursor setting
  16. old_cursor = SETCURSOR(SC_INSERT)
  17.  
  18. * If "echo" parameter is not passed, default is echo on
  19. IF echo_on = NIL
  20.     echo_on = .T.
  21. ENDIF
  22.  
  23. * Wait in loop for Y/N operator response
  24. keypress = 0
  25.  
  26. DO WHILE .T.
  27.  
  28.     * Get key
  29.     keypress = INKEY(0)
  30.  
  31.     IF CHR(keypress) $ 'YNyn'
  32.         EXIT
  33.  
  34.     ELSEIF (keypress <= K_F2 .OR. keypress >256 .OR.          ;
  35.            keypress = K_F1) .AND. TYPE('fkeyset') != 'U'
  36.  
  37.         * Call special keys procedure if any function key or
  38.         * Alt key combination is pressed. The variable,
  39.         * "fkeyset" must contain the procedure name.
  40.  
  41.         IF .NOT. EMPTY(fkeyset)
  42.             DO &fkeyset WITH 'OPCONFIRM', 0, READVAR(), keypress
  43.         ENDIF
  44.     
  45.     ELSE
  46.         ERRORBEEP()
  47.     ENDIF
  48. ENDDO
  49.  
  50. * Echo key at current position
  51. IF echo_on
  52.     @ ROW(), COL() SAY UPPER(CHR(keypress))
  53. ENDIF
  54.  
  55. * Reset cursor to entry state
  56. SETCURSOR(old_cursor)
  57.  
  58. * Return true on answer = "Y" or "y", otherwise, return false.
  59. RETURN  (IF (CHR(keypress) $ 'Yy', .T., .F.) )
  60.  
  61.