Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_OpenFile Dialog in same folder as exe
#13
(12-05-2022, 03:48 AM)DSMan195276 Wrote: I wouldn't recommend relying on `Command$(0)`, it's unreliable for this as it may have a relative path such as `./foobar/qb64pe.exe`. Stripping off the exe in that case will give you the path "./foobar", which will be treated relative to your current CWD and likely give you the wrong result since it's not absolute.

The best way to handle this would be saving the contents of `_CWD$` as soon as the program starts, since we always fill that with the location of the executable (discovered by OS-specific means other than `Command$(0)`).

If you're finding that `_CWD$` is unreliable for some reason at the start of the program then that sounds like a bug, but it really shouldn't be as it's fairly straight forward in what it does. I'd be curious to hear what behavior you're seeing where it's wrong.

OK it's possible I got confused which where I was. I have a nightmare jungle of GUI versions in a couple of places and loading files from IDE I sometimes mess up path... 

I will switch back to _Cwd$ if that is the one most likely to return the full or absolute path and try and pay more attention when using _OpenFileDialog$

Thanks for the an under-the-hood tip Smile

That slash thing still could be handy.
b = b + ...
Reply


Messages In This Thread
_OpenFile Dialog in same folder as exe - by bplus - 12-04-2022, 08:28 PM
RE: _OpenFile Dialog in same folder as exe - by bplus - 12-05-2022, 05:48 AM



Users browsing this thread: 20 Guest(s)