home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / lisp / 3147 < prev    next >
Encoding:
Text File  |  1992-12-28  |  1.7 KB  |  46 lines

  1. Newsgroups: comp.lang.lisp
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!att!cbnewsm!cbnewsl!davel
  3. From: davel@cbnewsl.cb.att.com (David Loewenstern)
  4. Subject: Re: a problem with reading a stream
  5. Organization: AT&T Bell Labs, Whippany, NJ
  6. Date: Mon, 28 Dec 1992 19:10:19 GMT
  7. Message-ID: <1992Dec28.191019.18212@cbnewsl.cb.att.com>
  8. In-Reply-To: rs69@cunixb.cc.columbia.edu's message of Sun, 27 Dec 1992 01:45:28 GMT
  9. References: <1992Dec27.014528.17943@news.columbia.edu>
  10. Lines: 34
  11.  
  12. ... On Sun, 27 Dec 1992 01:45:28 GMT, rs69@cunixb.cc.columbia.edu (Rong Shen) said:
  13. } Hi experts:
  14.  
  15. Barmar must be on vacation... so a non-expert will have to handle it 8^).
  16.  
  17. }         I am trying to write a function that asks a path to a file
  18. } from the user and opens the file to read. There is no problem with
  19. } opening the file, but when it tries to read, the interpreter
  20. } complains.
  21.  
  22.  
  23. } (defun read-path ()
  24. }   (format t "Enter the path to the file to read, e.g. /tmp/foo/faq.txt")
  25. }   (setf file-path-name (read-line))
  26. }   (setf what-stream (open file-path-name :direction :input)) ; ok
  27.  
  28. }   (read what-stream nil 'This-is-the-end-of-the-world)) ; This line has error;
  29.  
  30. Let me guess: faq.txt doesn't contain an s-expression?  Remember, READ
  31. reads an s-expression.  You may want READ-LINE, or READ-CHAR.
  32.  
  33. Also: it's usually bad style to use OPEN.  Use WITH-OPEN-FILE instead.
  34.  
  35. (WITH-STANDARD-DISCLAIMERS
  36.    (MAKE-INSTANCE 'Signature
  37.          :NAME      "David Loewenstern"
  38.          :LOCATIONS '((INTERNET "David.Loewenstern@att.com")
  39.                       (INTERNET "loewenst@paul.rutgers.edu")
  40.                       (AT&T "201-386-6516"))
  41.      :AFFILIATIONS '("AT&T Bell Labs" "Rutgers, Dept of CS")
  42.          :SILLY-QUOTE (UNIX:SHELL "/usr/bin/fortune"))))
  43.  
  44.  
  45.  
  46.