[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

timeout on y-or-n-p -- prob



                      timeout on y-or-n-p -- problems!
Thanks to the folks who suggested I look in the MKant utilities to find an
implementation
of timed-y-or-n-p.  I've been playing with the code, and it doesn't work for
me! It comes
down to the read-char-wait, which should return a character or NIL depending on

whether the timeout "expires" without seeing a character typed.

(defun internal-real-time-in-seconds ()
  (float (/ (get-internal-real-time) 
	    internal-time-units-per-second)))

(defun read-char-wait (&optional (timeout 20) input-stream &aux char)
  (do ((start (internal-real-time-in-seconds)))
      ((or (setq char (read-char-no-hang input-stream)) ;(listen *query-io*)
	   (< (+ start timeout) (internal-real-time-in-seconds)))
       char)))

Unfortunately, read-char-no-hang never seems to notice I have typed a
character,
and so always returns NIL.

It looks to me like a bug in read-char-no-hang, although I feel that is a hasty
conclusion.  Is there a known bug in read-char-no-hang? 

-David Wroblewski