[plt-scheme] Running but not stepping

From: Miguel Villaverde (mvillaverde at gmail.com)
Date: Fri Dec 25 16:19:07 EST 2009

Hi there. I've just noticed something strange while working on an exercise from HtDP, second edition. It's an exercise demonstrating function composition and simple input output via the typical Fahrenheit to Celsius conversion example (is it just me or every programming tutorial in the universe uses one of these?). Anyway, here's the code:

(require 2htdp/batch-io)

(define (f2c f)
  (* 5/9 (- f 32)))

(define (convert in out)
  (write-file out
              (number->string
               (f2c
                (string->number (read-file in))))))

(convert "sample.dat" "out.dat")

The thing is, the program works perfectly when run, but not so when I use the stepper (as recommended in the text: http://www.ccs.neu.edu/home/matthias/HtDP2e/fun.html). So if I run it with a sample.dat file containing the number 212 in the program folder, an out.dat file is created with the number 100, as expected. However, the stepper gives me the following error under the same conditions: 

read-file: expected <name of file in program's folder> as first argument, given: "sample.dat"

Why so?

Thanks,
Miguel





Posted on the users mailing list.