Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DAY 033: COMMAND$
#5
(12-13-2022, 07:53 PM)Pete Wrote: Nice catch!

I just tried this...

Made a routine with COMMAND$() and saved it as untitled.exe

Opened another instance of the IDE: RUN "untitled.exe"

It only showed the "untitled.exe" program name returned for COMMAND$(0).

So I then typed the full drive and path... RUN "C:\QB64PE\untitled.exe"

And it returned "C:\QB64PE\untitled.exe"

So it's the calling info it's collecting, rather than the actual drive and path of the app passing the arguments. That's needed for building any project that would not provide the full drive and path info.

So a more bullet proof method would be to pass the drive and path with _CWD$, something like..

Code: (Select All)
RUN "untitled.exe " + _CWD$

It needs to be a bit more involved. Add a space to pass it with other info, etc., but working with it should insure the correct drive and path from the calling program.

So I checked the first snippet and also found COMMAND$(0) include its own drive and path when it is run from the QB64 IDE, but when it RUNs itself, it only includes the program name.

I will make some edits accordingly in my original post for this, thanks!

Looks like #2 was the right choice in that app, today.

Pete

Your "bulletproof" method is a wee too complicated for my needs. All the parts are there for you; just just need to collect and assemble them for yourself:

Code: (Select All)
If InStr(_OS$, "WIN") Then slash$ = "\" Else slash$ = "/"
MyAppDir$ = _CWD$
MyAppName$ = Mid$(Command$(0), _InStrRev(Command$(0), slash$) + 1)
Print "My program directory is: "; MyAppDir$
Print "My program name is: "; MyAppName$
Print "My slash is: "; slash$
Print
Print "Put them all together for: "; MyAppDir$ + slash$ + MyAppName$

You might want to error check to make certain that the MyAppName$ has a ".exe" on the end of it for Windows (Linux and Mac don't use .exe), but otherwise that's the simple process to get your starting path, slash, and app name.
Reply


Messages In This Thread
DAY 033: COMMAND$ - by Pete - 12-13-2022, 06:48 PM
RE: DAY 033: COMMAND$ - by SMcNeill - 12-13-2022, 07:14 PM
RE: DAY 033: COMMAND$ - by Pete - 12-13-2022, 07:53 PM
RE: DAY 033: COMMAND$ - by SMcNeill - 12-13-2022, 09:12 PM
RE: DAY 033: COMMAND$ - by mnrvovrfc - 12-13-2022, 07:58 PM
RE: DAY 033: COMMAND$ - by SMcNeill - 12-13-2022, 09:26 PM
RE: DAY 033: COMMAND$ - by Dav - 12-14-2022, 01:21 AM
RE: DAY 033: COMMAND$ - by vince - 12-14-2022, 01:31 AM
RE: DAY 033: COMMAND$ - by SMcNeill - 12-14-2022, 01:43 AM
RE: DAY 033: COMMAND$ - by mnrvovrfc - 12-14-2022, 08:27 AM



Users browsing this thread: 1 Guest(s)