Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Equivalence of REM and :: syntax: Problem with if clause  (Read 2293 times)

0 Members and 1 Guest are viewing this topic.

thor.a

    Topic Starter


    Newbie

    Equivalence of REM and :: syntax: Problem with if clause
    « on: July 06, 2010, 02:33:28 AM »
    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,

    Thorsten

    thor.a

      Topic Starter


      Newbie

      Re: Equivalence of REM and :: syntax: Problem with if clause
      « Reply #1 on: July 06, 2010, 04:04:29 AM »
      Meanwhile 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

      Thorsten

      Salmon Trout

      • Guest
      Re: Equivalence of REM and :: syntax: Problem with if clause
      « Reply #2 on: July 06, 2010, 06:22:36 AM »
      Using double colon as REM substitute is unofficial and discouraged. It will break all parenthetical blocks including IF, FOR and && and || constructs.