Elvis Nguyen < XXXX@XXXXX.COM > writes:
By just doing what you said. But of course, you would have first to
say it correctly. It's not "while", it's "when" the line begins with
'R' that you want to process it.
(defun load-file-meta-tool (path)
(with-open-file (stream path) ; do not hard code pathnames!
; :direction :intput is the default so...
(let ((data '()))
(do ((line (read-line stream nil 'eof) ; what if the file is empty?
(read-line stream nil 'eof)))
((eq line 'eof)
;; "Reached end of file." ; And you find that funny?
;; Return something useful!
(when (and (plusp (length line)) (char= #\R (aref line 0)))
(let ((line (refine-reaction line))) ; do not use setf! let is more efficient.
;; DO NOT USE GLOBAL VARIABLES! values is more efficient!
(multiple-value-bind (name input output) (parse-reaction line)
(push (list name input output) data)
(format t "~%Name: ~a~&- Input: ~s~&- Output: ~s~&"
name input output))))))))