[plt-scheme] Loading at runtime

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Oct 6 22:26:35 EDT 2007

At Sat, 6 Oct 2007 20:30:04 -0400, "Matt Jadud" wrote:
> So I've created an executable. I want it to 'read' a datafile from the
> same directory as the executable. I don't know where that executable
> will end up... but I know the datafile will be in the same place.
> (Well, I'll check to see if it is first, and if it isn't, then I'll
> throw an error. But that's a digression.)
> Simply using 'open-input-file' with a "filename.dat" doesn't do the
> trick. 'define-runtime-path' gives me something that (on my Mac) will
> let me move the executable, but the datafile needs to be in the same
> place as I developed the executable... that is, the datafile and
> executable can't move together.

Do you mean that "filename.dat" is determined when you build the
executable? In that case, using `define-runtime-path' is the right
thing; create a "distribution" from the executable to package up the
executable and file so that they move together.

If you really want to manually find file relative to the executable,
though, then try

   (find-executable-path (find-system-path 'exec-file)


Posted on the users mailing list.