[plt-scheme] Loading at runtime

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Oct 6 23:57:22 EDT 2007

On Oct  6, Matt Jadud wrote:
> (define (dyn-file fname)
>     (let-values ([(base name x)
>                   (split-path
>                    (find-executable-path
>                     (find-system-path 'exec-file)))])
>       (case (system-type)
>         [(macosx)
>          (simplify-path
>           (build-path base 'up 'up 'up fname))]
>         [(windows) '...])))
> That feels ugly for what I'm trying to do.

You can add some sanity checking -- make sure that (on OSX) you're
climbing up a directory tree that has the right shape, like making
sure that you start from something that looks like

> That said, this gets me to a datafile that a user is going to
> modify, and the application will load data from that file at
> run-time. And for now, I'm "hard-coding" the fact that, no matter
> where the application lives, the datafile will be adjacent to the
> executable. Perhaps I should just pop open a 'File Open' dialog and
> be done with it... but this will do for the task at hand, I think.

Sounds like you expect your users to change the data outside of your
application -- and requiring that they do that in the application's
directory seems like a bad idea.  Much worse than popping up a dialog,
or asking them to drop the file onto some widget.

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

Posted on the users mailing list.