[plt-scheme] Windows and file I/O

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Oct 20 09:48:53 EDT 2006

On Oct 20, Chris Gehlker wrote:
> I hope really newby questions  are  tolerated here.
> 
> I'm trying to learn Scheme from the "Teach Yourself Scheme in Fixnum  
> Days" and I'm at the part about file I/O. I mostly use the  Mac and  
> everything seems to work there because Scheme accepts unix path  
> names. But when I  tried to move a toy application to Windows and use  
> forms like:
> 
> (open-output-file "C:\Documents and Settings\Chris Gehlker\My  
> Documents\greeting.txt")
> 
> I get an "unknown escape sequence \D in string" error. How do I
> specify paths in Windows without Scheme interpreting the backslashes
> as escapes?

Just like in many other languages, use

  (open-output-file "C:\\Documents and Settings\\Chris Gehlker\\My Documents\\greeting.txt")

or

  (open-output-file "C:/Documents and Settings/Chris Gehlker/My Documents/greeting.txt")

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.