Originally Posted by
bandent
Thank - you. I saw that post in an earlier search, but it appeared not to satisfy my needs. Maybe, I'm being a little slow seeing what it is doing.
With comments...
Code:
;;; Read contents of file and return list
;;; #File - File to read
;;; Alan J. Thompson, 11.11.09
(defun AT:ReadFile (#File / #List #File #Line)
(and
;; set and open file for reading
(setq #File (open (findfile #File) "R"))
;; each time you issue 'read-line' on a file, it will go to the next line,
;; so as long as it will allow me to read-line the file, it will define the value
;; to a variable...
(while (setq #Line (read-line #File))
;; value set as #Line, now I'll append it to a list eg. (list "A" "B" "C")
(setq #List (cons #Line #List))
) ;_ while
;; close file
(close #File)
) ;_ and
;; since I have to append from the front, my list is in reverse, so I just rearrange it.
(reverse #List)
) ;_ defun