Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
keyword to get the EXE name and the EXE path instead of parsing Command$(0) ?
#1
I could have sworn I saw something in the past month or 2 that looked like new keywords to get the EXE name of your program and the full path to where it was located (minus the EXE filename)... 

I tried searching the wiki, but didn't find anything, which is why I am asking.

It's not crucial, I can just do 

Code: (Select All)
Dim Shared m_ProgramPath$: m_ProgramPath$ = Left$(Command$(0), _InStrRev(Command$(0), "\"))
Dim Shared m_ProgramName$: m_ProgramName$ = Mid$(Command$(0), _InStrRev(Command$(0), "\") + 1)
but if there are now built-in keywords for this, I'd like to know.  Wink

Much appreciated...
Reply
#2
On startup a QB64 program implicitly does a CHDIR directory_of_exe$, so unless you do another CHDIR the full path to the exe's directory is just _CWD$. As far as I know the exe name will have to come from COMMAND$(0) as you indicated.
Reply
#3
Great, thanks!!
Reply
#4
(07-17-2025, 01:04 PM)luke Wrote: On startup a QB64 program implicitly does a CHDIR directory_of_exe$

I really hope not Huh
Most of my qb64 developed utilities are in D:\Utl which is in the PATH
I can theen use that utility from any directory where I want something to be done
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply
#5
If you want to preserve the working directory from when the user started the program, you should do a CHDIR _STARTDIR$ at the top of your program.
Reply
#6
(07-17-2025, 11:57 PM)luke Wrote: If you want to preserve the working directory from when the user started the program, you should do a CHDIR _STARTDIR$ at the top of your program.


       This actually caused me a slight bit of consternation  until I figured it out.    Perhaps the implicit CHDIR to  DIR_OF_EXE should be a compiler OPTION rather than an always on Default ????
Reply
#7
If not DIR_OF_EXE, then what should the default directory be?
Reply
#8
(07-19-2025, 04:29 AM)madscijr Wrote: If not DIR_OF_EXE, then what should the default directory be?

     I said it should be "Optional"  the other "option" would be to retain the current directory where the User starts it.  (currently saved in _startdir$).    Probably not so important for GUI apps but this would be the normal USER expectation when using a command line type utility.

     That's actually what caused me consternation.  I wrote such a utility and the program would not find the file name from the command line that I passed it.   Because it had changed the Directory to its own.     It wasn't a big deal after I figured it out.    BUT IT WAS UNEXPECTED !!
Reply
#9
we should all be happy.  we are using a different programming system.  from the powers-that-be that create gtk applications for linux.

i have to suck it up.  after i fire up gimp or such other program.  the first time i ask for an open file dialog.  to load in a document.  the system assumes the user's documents directory.  but it is seldom like that.  more often it's expected from programs written with qt.  instead this "recent" file listing.  i really would like that destroyed by fire.  or just edited away forever from source code.  it never lists at least one document i have read or changed with the same exact application!

however what qb64 does.  is no good when programs for unix and descendants.  are completely expected to be aligned in one directory.  actually applications in /usr/bin and vital operating system programs in /usr/sbin.  the data files are stored in a yet different place.  settings in another place still.  if there's any help documentation.  that's put in /usr/share/man or other similar place.

that is the biggest barrier.  to writing a program that assumes everything is in the "current" directory.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Command$(count%) - I can't get a value when using the optional argument "(count%)" Unatic 3 515 08-22-2025, 11:58 AM
Last Post: Unatic
  QB64 Common Keyword aadityap0901 3 567 06-07-2025, 11:04 PM
Last Post: SMcNeill
  Command$ issues eoredson 8 1,338 05-02-2025, 01:42 AM
Last Post: eoredson
  Locate command on the ttf graphical screens Helium5793 5 696 03-09-2025, 05:47 PM
Last Post: SMcNeill
  Bezier Path Generator TerryRitchie 4 1,145 10-07-2024, 04:59 PM
Last Post: Petr

Forum Jump:


Users browsing this thread: