[comp.lang.scheme] Opening files with Cscheme

les@unicads.UUCP (Les Milash) (07/14/89)

i have a thing called CScheme, which i love.  i have a manual called
RRRS.  i have a problem.

i'm trying to write a program that's c-preprocessor compatable, in that
it takes a -I/parameter -I/that/lists/a/bunch -I/of/directories/that
include files might be in.  so when the code includes foo.h i have to
find the first one of
	/parameter/foo.h
	/that/lists/a/bunch/foo.h
	/of/directories/that/foo.h
that exists.

RRRS talks about (open-input-file "filename") but if the file doesn't exist
i get an "out of range with "filename"" error and the program stops.

is there a way to figure out if some file exists without crashing?  or
some way to substitute some better error behaviour (i'd just as soon
have it return '() or #!the-you-screwed-up-object or something).
i have the CScheme source and am not adverse to making myself un-scheme-
compatable (but i imagine that scheme can do what i want somehow (else
what good is it?))

thanks in advance for the assistance!

Les Milash

wow! with a language like this, i might even be able to handle 
a shared-memory multiprocessor!

cph@ALTDORF.AI.MIT.EDU (Chris Hanson) (07/14/89)

   Date: 13 Jul 89 18:36:08 GMT
   From: Les Milash <unicads!les@boulder.colorado.edu>

   i have a thing called CScheme, which i love.  i have a manual called
   RRRS.  i have a problem.

   is there a way to figure out if some file exists without crashing?

The procedure `file-exists?' does what you want.  It takes a single
argument which is a filename.

les@unicads.UUCP (Les Milash) (07/15/89)

thanks, everyhody, for telling me about the function `file-exists?'.
you can stop now :-) you've been overwhelmingly helpful.


ya know, i've never gotten more code working faster than with this
wierd Scheme stuff!  i guess that's what it's all about, huh?