program directory
- Posted by Nick <metcalfn at ALPHALINK.COM.AU> Apr 22, 1999
- 523 views
Hi all. Wow, are the sparks flying in the Euphoria Listworld or what! Hehe, frankly I find it quite amusing, if a bit tiring... No more mention of that, though. :) A question: I have been wondering for a while now, how does one find out the directory a program is in when it was run? Not the directory it was run from, given by current_dir() or the location of ex.exe given by examining the command_line() (the program is not bound), but the location of the .ex file itself. for example.. I have a program, frog.ex in the directory c:\euphoria\progs\frog. It needs a data file in the same directory. Say a friend of mine gets the program, installs it in windows and double-clicks on the .ex icon. (he has .ex files calling ex.exe) My program will then look in c:\windows or some other strange place for it's data file, exiting ungracefully when it can't be found. I am reluctant to specify an absolute path to the data file, after all programs that force install into a particular directory kind of suck, huh. I can't tell my friend to change his system configuration either, just to run my program? no way! An installer that writes an ini or environment variable with the absolute location of the program is the very last contingency. Please, nooo.... I hope I have overlooked the obvious. Most of us appear to be content with looking in the current directory, or relative to it for data and images, hoping the user hasn't typed something like c:\>ex c:\euphoria\progs\frog.ex as I suspect happens sometimes, well maybe not, but windows does this kind of thing and one can't guarantee it won't happen after all. Something in the form: function get_program_dir() (workings) return dir end function so I can do the following: bitmap_name = "frog.bmp" program_dir = get_program_dir() frog = read_bitmap(program_dir & "\\" & bitmap_name) Any help is most appreciated. ------------------------------------------------------------------------------ Note for fractal lovers -- Fractal Factory is coming! Fractal Factory will the definitive fractal program in Euphoria. Yet another fractal program? well this one does things that even Fractint can't do.. it's not a patch on the speed of Fractint, sure enough, but it makes some quite startling images so far. And it's (nearly) 100% Euphoria! I have a lot of work to do on it yet, so it won't be available for some time to come but I have made some images and stuff available. Come and see at http://www.alphalink.com.au/~metcalfn if you're interested. Any suggestions, comments, ideas, input, feedback, contributions, collaborations and more are sought. ------------------------------------------------------------------------------ Many thanks to all, Nick