By registering with us, you'll be able to discuss, share and exchange private messages with other members of our community.

SignUp Now!

How to? %_CMDLine not working the way I thought the documentation says it does...

As usual, a TCC session (and there's not much there):
  Wed  Feb 29, 2012  5:02:36p
TCC  13.03.46  Windows 7 [Version 6.1.7601]
[Z:\]type TestManualArgumentPassing.btm
@Echo %%_CMDLine: %_CMDLine
[Z:\]TestManualArgumentPassing abc def=ghi jkl
%_CMDLine: TestManualArgumentPassing abc
As you can easily see, only the name of the command and the first argument were output, everything after that was dropped.

Now, from the documentation, "_CMDLINE returns the current command line. (This is most useful in key aliases.) If you specify it on the command line, it returns the contents of the command line with the %_cmdline name removed."

I left the whole description in because I am not trying to use it the "most useful" way; specifically I want to pass stuff to a batch file that TCC's command line parsing for batch files destroys. (Just to be clear as to why I am trying to do this, when I wrote C++ programs in the past I almost always did "keyword" arguments in the format "/Keyword=value", and even though I've now switched to TCC batch files I'd like to maintain the same syntax because I want it to be totally "transparent" to the user (i.e., me) whether any give program is a C++ program or a batch file.

And the reason this is a problem for me is because for reasons Rex told me many moons ago had to do with cmd.exe compatibility TCC "strips" the "=" sign from the argument list as seen by the batch file; i.e. "abc def=ghi jkl" becomes just "abc def ghi jkl" as seen by the batch file. Well this is a problem because I also write these things such that not coding the parameter at all lets it take a "default" value if there is one, whereas coding the parameter with no value specified (i.e. "/Keyword=") "nulls" the value of the parameter, i.e. it has no value at all rather than the default value. And it seems to me (bad memory playing a role here) %_CMDLine used to return the entire command line rather than just the command name followed by only the first parameter. (I must admit that I can't even imagine a case where that would be useful.)

So what am I doing wrong? Is there any way just to get the command line exactly as it was entered?

- Dan
Thank you, guys. You are both correct (but %* is a little bit better because I then don't have to deal with the command name); and Rex, the fact that it's "%CMDLine: rather than "%_CMDLine" tells me that memory in the matter was only slightly bad. :)

Similar threads