Hello,
Perhaps my previous message was too verbose, or there is someone still trying it out. After working on it some more, my question boils down to this:
How the heck do I use read-line in a program?
Take the following REPL session as an example:
Gambit v4.2.6
(read)
"This is an s-expression" ;<=typed "This is an s-expression" ;<=echoed
(read-line)
""
(read-line)This is an s-expression
"This is an s-expression"
So, I know that I can call read-line from call-with-input-file, or call-with-input-string, but if I have an input file or a string, then I already have what I want. What I want is for the user to input a line of text, and for the program to do something with that line of text (as a string).
However I use (read-line), it always accepts the text that was already there (usually "" or "\t"). How do I get it (or some other procedure) to accept user input? What would I put into (call-with-input-string ... read-line)? I've tried a few things, and I always just end up redefining read-line:
(define (read-this)
(let ((input (read-char)) (output "")) (if (char=? input #\newline) output (string-append (string input) (read-this)))))
(read-this)
""
(read-this)this is text, baby
"this is text, baby"
I'm really not getting this; can someone please explain it to me?
Thanks, Joel