QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: FilipeEstima on April 28, 2019, 05:51:10 pm
-
I am coding in a machine that has documents folder at D: drive, so whenever I have to get a file in that folder I use absolute path starting with D: - however, when the same program is ran at another PC where documents folder sits at C: drive, I get "Device unavailable". So, how can I properly determine the absolute path to the documents folder, that will allow the program to find it, no matter where it is running (by "no matter where" I mean any PC, any drive and any folder inside said PC)?
I suppose QB64 doesn't like use of system variable %documents%. I tried changing "D:documents" and the IDE complained. Is the only way to obtain the correct path in any computer via consulting Windows Registry?
-
Try:
-
Fellippe is faster :-D
My version: Path$ = ENVIRON$("homedrive") + ENVIRON$("homepath") + "\Documents"
-
Or maybe even:
-
Ah, Petr was faster this time.
Although _DIR$ is safer, as it gets info from the registry.
-
No, you are first in thread :-D
-
Thanks to both Fellippe and Petr, this is exactly what I needed. Although it doesn't work with all commands, since $EXEICON doesn't allow for string variable passed as argument :-(
-
Your icon should be in the same folder as your source code, or at least in a subfolder:
And it must be a literal because the icon is stored in the exe at compile time.
-
I found out that the icon doesn't really need to be in the same folder or subfolder of the source. It can be anywhere in the computer, provided the path is correct. Just tried putting it on another drive on a long path and it was found by the IDE.
-
It will be found, sure. It's just weird to place it elsewhere.