QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _STARTDIR$ function returns the user’s working directory when the program was started.


callPath$ = _STARTDIR$


The user’s working directory depends on how the program was launched. Note that these are ultimately controlled by the launching environment, so might differ in non-standard setups.

The value of _STARTDIR$ may differ from _CWD$ even at program start, because QB64 program change their current directory to the binary’s location. _STARTDIR$ is the directory inherited from the user’s environment, while _CWD$ will start off as the location of the program binary file. Because files are opened relative to _CWD$, this can be useful for programs that expect to open e.g. graphical or sound assets, but problematic for programs that want to interpret paths supplied by the user as relative to the user’s current directory. In the latter case, add a ‘CHDIR _STARTDIR$’ to the top of the program. This will change back to the working directory inherited from the environment.



Showcasing QB64 path functions:

SHELL "cd"

See Also