I have this code to read from a file some algorithm that came from a HTML
text area. I want that this code read (and compile) the file until the end
of file and not only the line (with "read-line"). How can I do this?
(setf *error-output* (open "erro" :direction :output))
(setf *standard-output* (open "saida" :direction :output))
(setf ?arq (open "input.lsp"))
(eval (read-from-string (read-line ?arq)))
(stream-error () (read-from-string "fim_do_arquivo")))
(cerror "Nenhum erro foi encontrado no código fornecido!")
From: Bruno Haible <haible@il...> - 2001-01-31 17:56:23
Leonardo Bitsch writes:
> I want that this code read (and compile) the file until the end
> of file and not only the line (with "read-line"). How can I do this?
One possibility is that you write a function 'read-contents' which
reads the contents of a stream until EOF, and returns it as a string.
Another possibility, if the stream may contain multiple Lisp forms, is
to call (load stream). 'load' also accepts streams, not only filenames.