_OpenFile Dialog in same folder as exe - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Utilities (https://staging.qb64phoenix.com/forumdisplay.php?fid=8) +---- Thread: _OpenFile Dialog in same folder as exe (/showthread.php?tid=1233) Pages:
1
2
|
_OpenFile Dialog in same folder as exe - bplus - 12-04-2022 I want the DefaultPathAndFile$ where my exe is. _StartDir$ sure didn't get it, that's my QB64 exe folder _Cwd$ works if I have been in folder for awhile but sometimes seems to be wrong when just starting cold. So I am trying this: Code: (Select All) Function ExePath$ Look alright? I add forward slash in case of Linux, Windows doesn't care. It seems to be working for all the tests I gave trying to get out of _CWD$ RE: _OpenFile Dialog in same folder as exe - Pete - 12-04-2022 That will work. I'm not happy _CWD$ isn't working 100%. Is it incorrect or just null. If it's a null return, you could always use a delay or... Code: (Select All) DO Pete RE: _OpenFile Dialog in same folder as exe - SMcNeill - 12-04-2022 _CWD$ is the current working directory. Say you start in D:\QB64, then CHDIR to D:\QB64\Files... _CWD$ at this point would tell you D:\QB64\Files. _STARTDIR$ tells you the directory that you started QB64 from. Let's say you're in Drive "C:\", and you start QB64 in "D:\QB64\qb64pe.exe". _STARTDIR$ will report "C:\" to you, as that's the directory you called QB64 from. Neither of these commands are guaranteed to tell you where your compiled program itself is located. COMMAND$(0), is the best place to look for that information, as you've noticed. RE: _OpenFile Dialog in same folder as exe - mnrvovrfc - 12-04-2022 Only one 32-bit long integer variable is necessary: Code: (Select All) Function ExePath$ RE: _OpenFile Dialog in same folder as exe - Pete - 12-05-2022 From the good ol' days of "Must I optimize everything you do!" or Variable? We don't need no stinkin' variable! Code: (Select All) PRINT ExePath$ Just sayin' Pete RE: _OpenFile Dialog in same folder as exe - Pete - 12-05-2022 I know, I know, for fun I should have.... Code: (Select All) PRINT ExePath$ Pete RE: _OpenFile Dialog in same folder as exe - bplus - 12-05-2022 Absolutely, what starts with a w and has 3 letters but ends with t I thought it was a joke about a wit missing an i, no... RE: _OpenFile Dialog in same folder as exe - Pete - 12-05-2022 Or the one about the guy who failed the one question math test: What do you get when you cut a wit in half? His answer, a half-wit. Well, he was half right... two half-wits. Pete RE: _OpenFile Dialog in same folder as exe - SMcNeill - 12-05-2022 Personally, I'd go this way: Code: (Select All) $If WIN Then Here we sort out our slash direction to begin with, and save it in a stored variable for use whenever it's needed in our program. After all, if it's needed to find ExePath, then it's going to be needed when we try and make use of that path and open a file, or anything else with it as well. RE: _OpenFile Dialog in same folder as exe - Pete - 12-05-2022 Not so fast there, Sparky. Sure, I recon Windows is the only OS that uses bsackslashes, but I'm just gettin' started on my Yosemite Vista OS with Smart ASCII Old-West technology. Then you'll be sorry when ya goes to run Steve's code, ya canrsarn galoots! - Sam |