Hi, I'm using a tool library of mine whose files are required by the main program and by other files of the same library as well.
My Gforth configuration adds <~/forth/> to 'fpath', and every Forth project or library of mine is in that directory. This means I can use the same path to require library files, no matter where: [Example 1] \ Main program: require my_library/file1.fs require my_library/file2.fs \ My Library's file1.fs: require my_library/file2.fs But that won't work if the program (with the required library files) is invoked with an unconfigured Gforth. My goal is to find a method that works in my environment and in any other Gforth as well, on any OS. I want to pack the program's directory, with the required library files in their own subrirectories, and be able to run it just with 'gforth program.fs' after unpacking it anywhere. Relative paths in all library files would solve the problem: [Example 2] \ Main program: require my_library/file1.fs require my_library/file2.fs \ My Library's file1.fs: require ./file2.fs But that creates a new problem: file2.fs would be included twice because the paths are different in both cases. It's not a big problem, but I'm trying to find a solution: I could search 'included-files' at the start of every library file, for the current filename without path, but that's too complex. A simple '[ifdef]' could be enough in every library file, but not in all cases. A symbolic link <my_library/my_library> pointing to <..> may work, but would not be a portable solution. Finally I've thought what seems a simple and definitive solution: The main program should include its own absolute directory into 'fpath'. Then library files in the packed program could be required the same way I use in my environment (example 1 above). Unfortunately 'sourcefilename' is useless here. I could get the absolute path to the current source file with the help of 'system', but that would not be a portable solution. Is there a Gforth-only way to get the absolute path to the directory where the current source file is been interpreted? Or the absolute path to the directory Gforth was invoked from? I've searched the manual and the sources without result. Thank you. Marcos -- http://programandala.net