1.

Solve : Equivalence of REM and :: syntax: Problem with if clause?

Answer»

Please CONSIDER the following example:
Code: [Select]@echo off

:: question: why is test1 correct but TEST2 not?
:: (tested on Windows XP)


echo test1:
if 1 equ 1 (
rem t1(): test1 works
)
echo ...works

echo test2:
if 1 equ 1 (
:: t2(): test2 throws a syntax error
)



Could somebody explain me why test2 fails?

Thank you very much in advance!

Best regards,

ThorstenMeanwhile I found the answer myself, it's always the same....:

http://www.robvanderwoude.com/comments.php

Quote

since DOUBLE colons are actually labels, they should be placed at the start of a command LINE; leading WHITESPACE is allowed, nothing else is
using double colons inside code blocks violates the previous "rule" and will result in errors
try to avoid comments inside code blocks, or use REM if you have to

ThorstenUsing double colon as REM substitute is unofficial and discouraged. It will break all parenthetical blocks including IF, FOR and && and || constructs.


Discussion

No Comment Found