I have a short racket program/script that reads a file from the directory in 
which it is stored. The directory structure is something like this:

        a/
                b/
                        c/
                                my-racket.rkt 
                                my-data-file.txt

I want to be able to run the program from the command line no matter what is 
the current working directory. E.G.:

        a> racket b/c/my-racket.rkt
        a/b> racket c/my-racket.rkt
        a/b/c> racket my-racket.rkt

In order to do so, I need to provide the correct path to my-data-file.txt 
depending on from where the script was launched. I haven’t learnt about Racket 
modules yet so I resorted to searching Stack Overflow. I found a code snippet 
that I used which worked:

(define script-dir (path-only (resolved-module-path-name
  (variable-reference->resolved-module-path
   (#%variable-reference)))))

Is this the best way to ascertain the directory of the “current module”?

Thanks in advance

Peter 


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/92DACE01-60C8-445A-A07E-A4E6A6F5F684%40gmail.com.

Reply via email to