[Solved]Get Current Directory Not Application Dir?

BlitzMax Forums/BlitzMax Programming/[Solved]Get Current Directory Not Application Dir?

RustyKristi(Posted 2016) [#1]
I'm writing a console app which needs to find out where it's currently running. The exe is placed on a folder (ex. C:/bin/) where it is included in PATH$ so I can execute it anywhere.

The problem is RealPath(".") and CurrentDir$() always returns the program directory and not where I'm currently executing the console application.

Any ideas?


Derron(Posted 2016) [#2]
I wanted to write you a working example - fiddled out that "appdir" is adjusted on startup ... and that there is a for-me-unknown-before command.

Searching the net for this command unveiled that it is even an official one ...

https://en.wikibooks.org/wiki/BlitzMax/Modules/BASIC/BlitzMax_runtime#LaunchDir

SuperStrict

Framework Brl.StandardIO
Import Brl.Retro

print "app path: " + AppArgs[0]
print "real path: " + CurrentDir()
print "app dir: " + AppDir
'THIS is what you want - seems to be undocumented, found it by looking
'why AppArgs[0] and AppDir report what they report
print "launch dir: " + LaunchDir



file resides in
~/Arbeit/Programmieren/Projekte/Testcodes/apppath (no .exe ending) and is made available via
$ export PATH=$PATH:/home/ronny/Arbeit/Programmieren/Projekte/Testcodes

~/Arbeit/Programmieren/Projekte $ apppath
app path: apppath
real path: /home/ronny/Arbeit/Programmieren/Projekte/Testcodes
app dir: /home/ronny/Arbeit/Programmieren/Projekte/Testcodes
launch dir: /home/ronny/Arbeit/Programmieren/Projekte


bye
Ron


RustyKristi(Posted 2016) [#3]
Ah!! as always thanks Derron! oooh I missed that one. Great find :D