ShadowThief wrote::: is technically a label
Are you sure? I'm not sure (maybe "::" is handled in a different way, when using in for loops):
Code: Select all
@echo off
for %%a in (1 2 3) do (
:: no label
:: no label
echo %%a
)
Result:
Code: Select all
Z:\>test
Das System kann das angegebene Laufwerk nicht finden.
1
Das System kann das angegebene Laufwerk nicht finden.
2
Das System kann das angegebene Laufwerk nicht finden.
3
I am using a german version of win xp home 32 bit, so the error message should be something like:
"The system cannot find the drive specified."
But it is possible to use a single "::" style comment (prior a following instruction line); if you want to use more lines you have to use the caret to make it one line:
Code: Select all
@echo off
for %%a in (1 2 3) do (
:: no label^
:: no label
echo %%a
)
In addition (with a trick) a label in the last line is possible, while a "::" style comment is impossible (without an error):
Code: Select all
@echo off
echo(last line in for: label
for %%a in (1 2 3) do (
echo(%%a
^:: no label
:label
)
echo(
echo(last line in for: no label
for %%a in (1 2 3) do (
echo(%%a
^:label
:: no label
)
At last please note that you cannot use some alternative echo formats, such as "echo(%%a" normally working in for loops, when using a "::" line prior:
Code: Select all
@echo off
echo(without comment
for %%a in (1 2 3) do (
echo %%a.1
echo(%%a.2
echo.%%a.3
)
echo(
echo(with comment
for %%a in (1 2 3) do (
:: 1
echo %%a.1
:: 2
echo(%%a.2
:: 3
echo.%%a.3
)
penpen