[plt-scheme] Creating Executable

From: Robert Bruce Findler (robby at cs.uchicago.edu)
Date: Sat Sep 7 20:26:48 EDT 2002

At 07 Sep 2002 20:54:41 +0100, Paulo J. Matos wrote:
> 
> > To flush stdout, use:
> > 
> >   (flush-output)
> > 
> > as in:
> > 
> >   (define (prompt-user-for-number)
> >     (printf "Number please: ")
> >     (flush-output)
> >     (read))
> 
> 
> Great! :)
> It's working now. But, how can I make (read-line) work in the
> example I sent. Somehow it is not workig. :(

I suspect the problem you are seeing is related to the way `read'
parses. It reads the characters until it encounters a complete
sexpression and no more. So, if your program is:

  (write (read))
  (write (read-line))

and your input is:

   a<return>

You will see that `read' consumes the `a' (and only the `a') and then
read-line reads the rest of that line, which means it gets the empty
string.

I'm not sure what to suggest to fix this problem, however. I'm not sure
how well read and read-line are going to work together. Others might
have ideas (or you could build a GUI ;).

Robby



Posted on the users mailing list.