[plt-scheme] Loading at runtime

From: Matt Jadud (jadudm at gmail.com)
Date: Sat Oct 6 20:30:04 EDT 2007

Hi all,

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.

It doesn't seem like "this-expression-source-directory" is what I want.

How do I open a file relative to the executing program I've bundled
for distribution? I feel like this should be obvious, but I'm missing
it at the moment. No doubt, I'll find it in the Help Desk


Posted on the users mailing list.