Código:
@echo off
rem Aqui va todo el codigo
(Todo esto no será ejecutado
Es importante no cerrar el parentesis, ya que si se cierra sera ejecutado lo que
esta dentro del parentesis.
Debe de usarse solo al final de los codigos.
Hasta ahorá se podian usar comentarios de estas formas :
Código:
@echo off
REM COMENTARIO
::COMENTARIO
% COMENTARIO %
PAUSE
EXIT /B
Una curiosidad :
Cuando usamos un comentario de este tipo :: en un FOR, saldrá error, prueben esto :
Código:
@ECHO OFF
FOR %%X IN (NOTEPAD.EXE) DO (
::COMENTARIO SOLO
)
Una explicación sería que ::COMENTARIO SOLO, no es tomado en cuenta, y dará error al tener los () solos.
Es igual a hacer esto :
Código:
@ECHO OFF
FOR %%X IN (NOTEPAD.EXE) DO ()
También se obtiene error en el IF :
Código:
@ECHO OFF
SET A=1
IF %A%==1 (
ECHO HOLA
::ALGO
)
PAUSE>NUL
Código
@ECHO OFF REM COMENTARIO ::COMENTARIO % COMENTARIO % (COMENTARIOS: NUEVA FORMA DE COMENTARIOS LEO GUTIERREZ
Cita de Rob Van der Woude :
Citar
I must confess, this tip by Leo Gutierrez Ramirez baffled me.
I didn't expect it to work, but it does.
See for yourself:
@ECHO OFF
REM Code:
ECHO Hello
REM Comments:
(COMMENT
HELLO!
HI!
The trick is not in the exclamation marks, it is the fact that the parenthesis opens a "code block" which is never closed, and thus seems to be ignored completely by the command interpreter.
As Leo said: a useful way to add comments at the end of a batch file.
Thanks Leo
I didn't expect it to work, but it does.
See for yourself:
@ECHO OFF
REM Code:
ECHO Hello
REM Comments:
(COMMENT
HELLO!
HI!
The trick is not in the exclamation marks, it is the fact that the parenthesis opens a "code block" which is never closed, and thus seems to be ignored completely by the command interpreter.
As Leo said: a useful way to add comments at the end of a batch file.
Thanks Leo
Código:
http://www.robvanderwoude.com/clevertricks.html