Yes, I understand... Thanks again!jeb wrote:No it starts only once, the second delay is in the echo %%a itself.
Unfortunately, I gave out wished for the valid. It turns out that substitution doesn't work for new CMD call...
Moderator: DosItHelp
Yes, I understand... Thanks again!jeb wrote:No it starts only once, the second delay is in the echo %%a itself.
Delayed Expansion can work also in a new (indirect) CMD call, if it is turned on via registry keys.amel27 wrote:Unfortunately, I gave out wished for the valid. It turns out that substitution doesn't work for new CMD call...
jeb wrote:Ok, now we have a problem, there is only one usable character left.
The "(", which I agree with you, that this presumably has other side effects.
Code: Select all
@echo off
setlocal enableDelayedExpansion
cls
call :test "echo:"
call :test "echo."
call :test "echo("
call :test "call echo("
exit /b
:test
echo ------------------------------
echo cmd=%~1
set "cmd=%~1"
%cmd%Immediate expansion
%cmd%!cmd:~0,4! Immediate expansion with delayed substring
for /f "delims=" %%c in ("!cmd!") do %%cFOR variable expansion
for /f "delims=" %%c in ("!cmd!") do %%c!cmd:~0,4! FOR variable expansion with delayed substring
!cmd!Delayed expansion
!cmd!!cmd:~0,4! Delayed expansion with delayed substring
exit /b
Code: Select all
------------------------------
cmd=echo:
Immediate expansion
cmd:~0,4 Immediate expansion with delayed substring
FOR variable expansion
cmd:~0,4 FOR variable expansion with delayed substring
Delayed expansion
cmd:~0,4 Delayed expansion with delayed substring
------------------------------
cmd=echo.
Immediate expansion
cmd:~0,4 Immediate expansion with delayed substring
FOR variable expansion
cmd:~0,4 FOR variable expansion with delayed substring
Delayed expansion
cmd:~0,4 Delayed expansion with delayed substring
------------------------------
cmd=echo(
Immediate expansion
echo Immediate expansion with delayed substring
'echo(FOR' is not recognized as an internal or external command,
operable program or batch file.
The filename, directory name, or volume label syntax is incorrect.
'echo(Delayed' is not recognized as an internal or external command,
operable program or batch file.
The filename, directory name, or volume label syntax is incorrect.
------------------------------
cmd=call echo(
Immediate expansion
call Immediate expansion with delayed substring
FOR variable expansion
cmd:~0,4 FOR variable expansion with delayed substring
Delayed expansion
cmd:~0,4 Delayed expansion with delayed substring
pyotr wrote:For what is is worth, I just ran accross this problem "ech not a valid command"
Code Sample
:WrongProg
color 47
Echo.
Echo Error - either wrong program or wrong computer
Echo.
Echo. Are We home?
set tag= "Wrong Drive maybe"
>> %LogFile% Echo. %tag%
Only another easy to avoid problem, you cannot use "echo(" within a for loop after a "::"/":" line:dbenham wrote:jeb wrote:Ok, now we have a problem, there is only one usable character left.
The "(", which I agree with you, that this presumably has other side effects.
So has anyone found any problems with ECHO(
The only problem I can find is the ECHO( command cannot be in a variable "macro" that is expanded with delayed expansion or FOR variable expansion.
Code: Select all
@echo off
for %%a in (a) do (
:: 123
echo( 1
echo( 2
:123
echo( 3
)
goto :eof
Code: Select all
@echo off
for %%a in (a) do (
:: 123
^
this seems to be a parameter of "^(\r)?\n(\r)?\n" will never be executed
echo( 1
echo( 2
:123
^
echo( 3
)
^
this works outer for loops, too
Code: Select all
@echo off
(
:: Label comment
^
Ignored if after a label comment within parentheses
echo(1
:label
^
Also ignored if after a label comment within parentheses
echo(2
REM The empty "command" within parentheses works OK without a preceding label if there is no comment included
^
echo(3
^
But this fails because it is within parentheses but does not follow a label
echo(4
)
^
This is ignored outside of parentheses without a preceding label
:label
^
This is also ignored after a label
:: Label comment
^
And this is ignored after a label comment
echo Done
penpen wrote:Reminds me to the macro comments, but without the "<nul" part.