;;;  File: Echo.lsp
;;; 
;;;  Show how to read a line of text as a string
;;; 
;;;  Author:  Bary W Pollack
;;;  Date:    Apr. 23, 2007
;;; 

;;;  --------------------------------------------------------------
;;;  Echo will echo its input -- assumed to be a line ending with [Enter]

(defun echo () "A simple echo program" (let* ((aLine NIL))
	(terpri)
	(princ "End your sentences with the usual punctuation.  Any ") (terpri)
	(princ "sentence with the word ") (princ "'")(princ 'LISP)(princ "'") (princ " in it will take you back ") (terpri)
	(princ "to top-level LISP.  Now type away...") (terpri)
	
	(setq aLine (s2l (string-right-trim "?" (read-line))))
		(loop until (member 'LISP aLine) do
			(format t "~%Type a line: ")
			(setq aLine (s2l (string-right-trim "?" (read-line))))
			(cond 
				((member 'lisp aLine) (return (format t "~&See you later!~&")))
 			)
			(format t "You said: \"~S\"" aLine)
		)
))

;;;  --------------------------------------------------------------

(defun s2l (str) "make a string into a list, found at http://grimpeur.tamu.edu/~colin/lp/node63.html"
	(do* ((stringstream (make-string-input-stream str))
		(result nil (cons next result))
		(next (read stringstream nil 'eos)
		(read stringstream nil 'eos)))
	((equal next 'eos) (reverse result))
))
