Author Topic: Possible bug? Difficulty passing parameters to a QB64 program with COMMAND$  (Read 3161 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
Re: Possible bug? Difficulty passing parameters to a QB64 program with COMMAND$
« Reply #15 on: December 17, 2020, 08:01:54 am »
Thanks for chiming in, @mpgcan.

The rules above come from https://docs.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments?view=msvc-160&viewFallbackFrom=vs-2017

The code sample provided in that page, simplified/adapted to be compiled with the c compiler we ship:

Code: C++: [Select]
  1. // ARGS.C illustrates the following variables used for accessing
  2. // command-line arguments and environment variables:
  3. // argc  argv  envp
  4. //
  5.  
  6. #include <stdio.h>
  7.  
  8. void main( int argc, // Number of strings in array argv
  9. char *argv[],      // Array of command-line argument strings
  10. char **envp )      // Array of environment variable strings
  11. {
  12.     int count;
  13.  
  14.     // Display each command-line argument.
  15.     printf( "\nCommand-line arguments:\n" );
  16.     for( count = 0; count < argc; count++ )
  17.         printf( "  argv[%d]   %s\n", count, argv[count] );
  18.        
  19.     return;
  20. }

The result:

  [ You are not allowed to view this attachment ]  

As I stated earlier, there's nothing in the QB64 code that's stripping backslashes. The behavior is inherent to Windows' handling of the command line.

FellippeHeitor

  • Guest
Re: Possible bug? Difficulty passing parameters to a QB64 program with COMMAND$
« Reply #16 on: December 17, 2020, 08:27:26 am »
The workaround, as also indicated above, is to double the last backslash:

  [ You are not allowed to view this attachment ]  

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Re: Possible bug? Difficulty passing parameters to a QB64 program with COMMAND$
« Reply #17 on: December 18, 2020, 02:15:01 am »
Thanks. I very much appreciate the analysis. What's odd is that I don't see anything in those rules to explain this particular result:

C:\QB64_Test>test "\\?\Volume{06b8848c-3cfc-11eb-a783-60f2624ff3b8}\My Media"
Parameter 1 is : \\My Media

However, I'm not really going to spend any more cycles figuring that part out because it's a moot point now.

Fortunately, this was going to be for a rather small utility and I can write this up as a batch file easily enough.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Possible bug? Difficulty passing parameters to a QB64 program with COMMAND$
« Reply #18 on: December 18, 2020, 02:22:54 am »
\\My Media is probably a system mapped shortcut, like My Music and My Pictures.

The full path would be something like C:\Users\Bob\My Media, with a network mapping of \\My Media as a shortcut to them.

For whatever reason, windows is returning and passing the registered shortcut rather than the full path, for this shortcut.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!