REM
REM testparm.bat:
REM
REM show all command line parameters
echo %*
REM show individual parameters
echo %1 %2 %3 %4 %5
REM end
This is what happens when I pass five parameters (parameter three is a
comma):
C:> testparm.bat now is , the time six
C:>echo now is , the time
now is , the time
C:>REM show individual parameters
C:>echo now is the time
now is the time
C:>REM end
Here you can see that the first echo (all parameters) includes the
comma but the positional parameter is ignored. In fact, there are
only five positional parameters that should be echoed in the second
echo statement but the sixth argument is echoed. I've even tried
attaching the comma to another character but it disappears from the
positional arguments while it always is displayed by the %*
How can I get the comma to be recognized as a parameter?
> How can I get the comma to be recognized as a parameter?
You can't - it's a command line delimiter. You *have* to quote it. Same
with spaces, and several other characters that mean something to the
command processor.
--
T.E.D. (tda...@mst.edu)
If you explain what you need to do then there may be a way to solve the
issue.
@echo off
setlocal
set p=%*
set p=%p:,=^^,%
set n=1
:loop
for /f "tokens=%n%" %%i in ('echo %p%') do set p%n%=%%i
set /a n=n+1
if not %n%==6 goto :loop
echo parameter 1 : %p1%
echo parameter 2 : %p2%
echo parameter 3 : %p3%
echo parameter 4 : %p4%
echo parameter 5 : %p5%