Path problem

BlitzMax Forums/BlitzMax Beginners Area/Path problem

Wiering(Posted 2006) [#1]
I'm having a hard time making a simple console program that will accept a file name on the command line. BlitzMax changes the directory to where the executable is located and the current directory is lost.

The best solution I've found so far to start with:

ChangeDir (LaunchDir)

But this doesn't always work across drives, for example, if my current directory on C: is something like "Documents and Settings\My Documents" and from D: I start my application with command line "C:FILE.TXT", it isn't found, I have to inlcude the full path "C:\documents and settings\my documents\FILE.TXT".

So is there a way to get the current directory on a different drive? Or can I prevent Blitz from changing the directory in the first place?


tonyg(Posted 2006) [#2]
Launchdir on its own should do it... shouldn't it?
P.S. Not sure what you mean by 'current directory'.


Dreamora(Posted 2006) [#3]
Current directors (called working directory) is the directory from which the app is executed. This is not always the same as in which the app itself is.

So you shouldn't change the dir at all if you want it to see the startdirectory as the current one.
But even then: C:File.TXT is no valid filename. Its just file.txt.
What you try there is some strange mixing of path as it is either just file.txt or c:/file.txt (or \, thats no dif) in which case the current dir is of no importance ...


Wiering(Posted 2006) [#4]
This works fine in any other programming language, and if you often work with a DOS prompt, you rely on it to work (that saves you from typing all those long path names each time). Every drive has its own current directory.

For example, the command "notepad c:file.txt" uses file.txt in the current directory on C:, not C:\Windows or whereever your Notepad.exe is located.

To me, it seems wrong that Blitz changes the directory, it's something the programmer could choose to do.


H&K(Posted 2006) [#5]
Ah, I get it. You mean like in 6.1 when if you typed in a:
it would go to the last directory that you Dir'ed in A, and not the the root of a.

That always anoyed me. Never got it right. Would do things like

Copy *.* A:

What that going to do? Move it to the root of A or to the last Dir of A?

Im glad BMAx doesnt work like that, it was a pain in the ass. If on the other hand you think that It should, just write the new system yourself. Honestly if you know what you want it to do, you can probably have it finished in half a day, easy.

Im slowly coming to the opinion that once you know what you are doing, you should (Time permitting), rewrite the mods to be just as you want them.


Brendane(Posted 2006) [#6]
If you feel adventurous you could always comment out this line from blitz_app.c in the blitz.mod (function bbStartup() ) :-

chdir( app_dir );

and rebuild modules.

Not sure what impact this might have on gui apps but you always have access to the AppDir$ global. At least you would have a 'proper' console app. (ie. one which does not change the working directory).