Closed DualBrain closed 1 year ago
After some discussion in Discord, I'll add/clarify.
C:\
test\
readme.md
source\
sample.bas
sample.exe
content of sample.bas
PRINT _STARTDIR$
Open VSCode in the test folder (as this is what GitHub Desktop does).
Open sample.bas... press F5.
The output would be c:\test
; I contend it should be c:\test\source
as this is how I typically experience this in QB45, VB, C#, etc.
If I, however, double click on sample.exe in Explorer... the output would be c:\test\source
(as expected).
Changing the command (for windows) to "command": "${config:qb64.installPath}/qb64.exe -c -x \"${fileDirname}\${fileBasename}\" -o \"${fileDirname}\${fileBasenameNoExtension}.exe\" -x; if ($?) {cd ${fileDirname}; start \"${fileDirname}\${fileBasenameNoExtension}.exe\"}"
Should fix it. I will need to update the auto created launch.json
This has been fixed in Windows only.
Leaving open until Linux and Mac OS are fixed as well
Confirming fix appears to be working (for windows at least).
This has been setting for 3 months. Marking done.
I'm going to try to walk through this using the https://github.com/DualBrain/QuickPakPro/ project.
The folder structure of the project is setup such that the README.md and other "high level" stuff is in the root of the folder. The majority of the source code is located in a QB64 folder (this could easily be called something like SOURCE, but I have my reason(s)).
When I have this on my machine, I typically use GitHub Desktop to jump between different projects and it contains a nice feature "Open in Visual Studio Code". Doing so, it will open the root of this project folder in VSCode and this is where (I believe) the problem roots itself.
Inside of the QB64 folder, I then find my sample that I wish to work with. I then press F5... the problem though is that there is then a difference between what the sample executing sees as the current working folder versus if I launch the compiled executable outside of VSCode. What I mean is that the compiled executable is located in the same folder as the .BAS file... this is the desired result. However, if VSCode launches the compiled executable (as part of the F5 process), the executable things the starting folder is the root of the project... not the same folder as where the executable is. If, however, I was to double click on the executable in Windows... things are working as expected.
One key point here is that I am using
CHDIR _STARTDIR$
in my code to "reset" the current "working" folder used by the file functionality to be the location specified as the start folder.In my mind, this start folder should be the location of the executable (by default), not the root of the project.