0

I get an error that dataInput is not bound. I don't know why. It seems like a valid let expression. Please explain. Thanks very much!

 (define imageList "/home/perry/dir_image_search_list") ;text file of image exif data in a proper list
 (if (file-exists? imageList)
     (let ((dataInput (open-input-file imageList)) 
           (raw-data (read dataInput))) ;dataInput is not bound for some reason
         (if (eof-object? raw-data)
             (begin
                 (display "file is empty")
                 (close-port dataInput)
                 '()
             )
         (begin
             (car raw-data) ;placeholder for future code to process the list
             (close-port dataInput)
         ))
     )
     (begin
         (display "file not found")
         '()
     )
 )
Barmar
  • 741,623
  • 53
  • 500
  • 612
Trenton J
  • 25
  • 3
  • 1
    You have to use `let*` if you want to refer to a variable in a later binding in the same expression. – Barmar Apr 28 '23 at 17:34
  • You might also want to read up on `call-with-input-file`, `cond` and standard Scheme/lisp family formatting conventions. – Shawn Apr 28 '23 at 21:38

0 Answers0