(read-line [file-descriptor])


Read a whole line.


The read-line function is similar to the read-char function, but is generally much more practical and efficient to use. Anything can be read from a file, since the format is a string. The file is specified by the file-desc, assigned by the open(open filename mode)(IDR_237) function.

Example

For the following example, assume the file sample.lsp exists, the first line is "C:\Sample\First.txt", and the second line is "Second Line".

Code Returns
(setq file (open "sample.lsp" "r"))  
(setq c (read-line file)) "C:\\Sample\\First.txt"
(setq d (read-line file)) "Second Line"

NOTES

  • The read-line function automatically moves to the next line in the file; it returns the next line from the file.
  • When read-line reaches the end of the file, it returns nil.

Tell me about...

(setq symbol1 statement1 [symbol2 statement2] ...)

(write-line string [file-descriptor])

LISP Compatibility

Programming Overview of LISP (LISt Processing) Language