home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION OPCONFIRM (echo_on)
- *****************************************************************
-
- * Wait for operator confirmation in "Y/N" format
-
- * Copyright(c) 1991 - James Occhiogrosso
-
- #include "set.ch"
- #include "inkey.ch"
- #include "setcurs.ch"
-
- LOCAL keypress, old_cursor
-
- * Save entry cursor setting
- old_cursor = SETCURSOR(SC_INSERT)
-
- * If "echo" parameter is not passed, default is echo on
- IF echo_on = NIL
- echo_on = .T.
- ENDIF
-
- * Wait in loop for Y/N operator response
- keypress = 0
-
- DO WHILE .T.
-
- * Get key
- keypress = INKEY(0)
-
- IF CHR(keypress) $ 'YNyn'
- EXIT
-
- ELSEIF (keypress <= K_F2 .OR. keypress >256 .OR. ;
- keypress = K_F1) .AND. TYPE('fkeyset') != 'U'
-
- * Call special keys procedure if any function key or
- * Alt key combination is pressed. The variable,
- * "fkeyset" must contain the procedure name.
-
- IF .NOT. EMPTY(fkeyset)
- DO &fkeyset WITH 'OPCONFIRM', 0, READVAR(), keypress
- ENDIF
-
- ELSE
- ERRORBEEP()
- ENDIF
- ENDDO
-
- * Echo key at current position
- IF echo_on
- @ ROW(), COL() SAY UPPER(CHR(keypress))
- ENDIF
-
- * Reset cursor to entry state
- SETCURSOR(old_cursor)
-
- * Return true on answer = "Y" or "y", otherwise, return false.
- RETURN (IF (CHR(keypress) $ 'Yy', .T., .F.) )
-
-