From: Joris Van Looveren
Subject: Read input in Allegro CL
Date: 
Message-ID: <5vmbtr$krp@rc1.vub.ac.be>
Hi,

Can anyone help me with the following problem?

I want to write a loop that occasionally checks for keyboard input.
If there is no input, it should continue without stopping. If there
is input, it must execute some code to check it. Something like this:

(do ()
    ((eq (read-char-no-hang) #\s) 'ok)
  ...
)

I have tried using (listen) and (read-char-no-hang) to check for
keystrokes, but they never see one. The keystrokes appear on the screen
when the loop has finished executing.

I use Allegro CL 3.0.2 for Windows.

Thanks,


Joris.
-- 

                                      \ \    / /    Joris Van Looveren
                                       \ \  / /     ·······@vub.ac.be
 ___________________________________ ___> \/ <____  VUB - Brussel
From: William Paul Vrotney
Subject: Re: Read input in Allegro CL
Date: 
Message-ID: <vrotneyEGMxA9.Aq6@netcom.com>
In article <··········@rc1.vub.ac.be> Joris Van Looveren <·······@vub.ac.be>
writes:
> 
> Can anyone help me with the following problem?
> 
> I want to write a loop that occasionally checks for keyboard input.
> If there is no input, it should continue without stopping. If there
> is input, it must execute some code to check it. Something like this:
> 
> (do ()
>     ((eq (read-char-no-hang) #\s) 'ok)
>   ...
> )
> 
> I have tried using (listen) and (read-char-no-hang) to check for
> keystrokes, but they never see one. The keystrokes appear on the screen
> when the loop has finished executing.
> 
> I use Allegro CL 3.0.2 for Windows.
> 

Hmm... if it's any help, it works for me in Allegro CL 3.1.20.  It also
works in GCL and Clisp.  If it is not the earlier version of Allegro problem
it may be an OS problem.  In either case try putting in

        (sleep 1)       ; or (sleep 2)

in the loop and see if it makes any difference.


-- 

William P. Vrotney - ·······@netcom.com