Obtaining Application Path

Blitz3D Forums/Blitz3D Beginners Area/Obtaining Application Path

Blitzplotter(Posted 2006) [#1]
I have been considering using the following way to read whatever path a 3Dblitz.exe is running from, :- Currentdir.

I can write to and read from static / hard coded paths but am struggling to find out what path an application 'could' be running from. i.e. if a user of my application decided he wanted to run his copy of my application from his F:/drive instead of his c:/drive.....


GfK(Posted 2006) [#2]
Erm.... use CurrentDir() ??

...or am I completely misunderstanding the problem?

but am struggling to find out what path an application 'could' be running from.
It can *only* be running from wherever it was when you double-clicked on it.


Dreamora(Posted 2006) [#3]
wrong!
If you create a link to it, you can change the running dir to whatever you like. But most apps don't handle that situation and simply break because they don't find the media in their current directory. So I would not mind that situation. It only breaks if user do manually exchange the "calling from path" part.


big10p(Posted 2006) [#4]
SystemProperty("appdir") returns the directory your exe is located in.


Blitzplotter(Posted 2006) [#5]
Hmmm, never used 'system properties' within my Blitz exes before - appdir does sound less liable to corruption - Is the proper way to use appdir just to substitute currentdir eith appdir ?


big10p(Posted 2006) [#6]
What I do is, use CurrentDir to get the app path. Then, before building the exe, I add 'ChangeDir SystemProperty("appdir")' as the first line of code. However, I don't think it's strictly necessary to add this line anymore. I used to do it to ensure CurrentDir returned the app dir, even when launched from a shortcut - I think blitz does this automatically now, though.

Just using CurrentDir should be OK, as long as you haven't used ChangeDir, somewhere else in your code. In fact, just plonk the following line at the start of your code, and all should be fine.
Global app_dir$ = CurrentDir$



Beaker(Posted 2006) [#7]
You mean:
Global app_dir$ = CurrentDir()


big10p(Posted 2006) [#8]
Erm, yeah. :P


Sir Gak(Posted 2006) [#9]
.....


Blitzplotter(Posted 2006) [#10]
Thanks for the tips folks, I've just been playing around with Inno setup - a very easy to understand install application. I will be incorporating your 'tips', cheers again....