|
| |
.Rem
Description
- Allows comments to be placed anywhere in a script that a normal command would be accepted.
- Overcomes the limitations of the built-in REM command as
well as commonly used alternatives such as ":: Comment".
- Can be dynamically redefined to let comments be displayed for testing or clarity of execution.
Syntax
Parameters and Switches
|
Optional Text |
|
Optional comment (display can be toggled
on or off with .ShowComments and .HideComments) |
Errorlevels and Output Variables
Examples, Notes and Instructions
REM_Demo.cmd
01. @ECHO OFF
02.
SETLOCAL ENABLEEXTENSIONS
03.
04. IF
/I "%1"=="REM" GOTO:CASE1
05. IF
/I "%1"=="::" GOTO:CASE2
06. IF
/I "%1"==".Rem" GOTO:CASE3
07.
08. ECHO:REM_Demo
[ REM ^| :: ^| .Rem ]
09.
%.ExitEL1%
10.
11. :CASE1
12.
13.
%.DashLine%
14. ECHO:[internal
REM command]
15.
%.DashLine%
16.
17. FOR %%A
IN (1 2 3) DO (
18. (ECHO:[%%A]
Before the remarked line)
19. (REM [%%A] ***EMBEDDED COMMENT***)
20. (ECHO:[%%A]
After the remarked line)
21. )
22.
23. GOTO:FINISH
24.
25. :CASE2
26.
27.
%.DashLine%
28. ECHO:[Commonly
used :: technique]
29. %.DashLine%
30.
31. FOR %%A IN (1 2 3) DO (
32. (ECHO:[%%A]
Before the remarked line)
33. (:: [%%A] ***EMBEDDED COMMENT***)
34. (ECHO:[%%A]
After the remarked line)
35. )
36.
37. GOTO:FINISH
38.
39. :CASE3
40.
41.
%.DashLine%
42. ECHO:[Mount/\Command
.Rem]
43. %.DashLine%
44.
45. FOR %%A IN (1 2 3) DO (
46. (ECHO:[%%A]
Before the remarked line)
47. (%.Rem% [%%A] ***EMBEDDED COMMENT***)
48. (ECHO:[%%A]
After the remarked line)
49. )
50.
51. GOTO:FINISH
52.
53. :FINISH
54.
55. %.UnderLine%
56. %.dtEcho%
End of Script [%~nx0]
57.
%.ExitEL0%
NT
2K
XP
K3 |
C:\GuardPost>REM_Demo
REM_Demo [ REM | :: | .Rem ]
C:\GuardPost>REM_Demo REM
-----------------------------------------------------------------------------
[internal REM command]
-----------------------------------------------------------------------------
The syntax of the command is incorrect.
C:\GuardPost>REM_Demo ::
-----------------------------------------------------------------------------
[Commonly used :: technique]
-----------------------------------------------------------------------------
[1] Before the remarked line
The filename, directory name, or volume label syntax is incorrect.
[2] Before the remarked line
The filename, directory name, or volume label syntax is incorrect.
[3] Before the remarked line
The filename, directory name, or volume label syntax is incorrect.
_____________________________________________________________________________
[Mon 03/17/2003 05:39:08] End of Script [REM_Demo.cmd]
C:\GuardPost>REM_Demo .Rem
-----------------------------------------------------------------------------
[Mount/\Command .Rem]
-----------------------------------------------------------------------------
[1] Before the remarked line
[1] After the remarked line
[2] Before the remarked line
[2] After the remarked line
[3] Before the remarked line
[3] After the remarked line
_____________________________________________________________________________
[Mon 03/17/2003 05:39:17] End of Script [REM_Demo.cmd]
C:\GuardPost>%.ShowComments%
C:\GuardPost>REM_Demo .Rem
-----------------------------------------------------------------------------
[Mount/\Command .Rem]
-----------------------------------------------------------------------------
[1] Before the remarked line
[1] ***EMBEDDED COMMENT***
[1] After the remarked line
[2] Before the remarked line
[2] ***EMBEDDED COMMENT***
[2] After the remarked line
[3] Before the remarked line
[3] ***EMBEDDED COMMENT***
[3] After the remarked line
_____________________________________________________________________________
[Mon 03/17/2003 05:39:32] End of Script [REM_Demo.cmd]
C:\GuardPost>%.HideComments%
C:\GuardPost>REM_Demo .Rem
[Mount/\Command .Rem]
-----------------------------------------------------------------------------
[1] Before the remarked line
[1] After the remarked line
[2] Before the remarked line
[2] After the remarked line
[3] Before the remarked line
[3] After the remarked line
_____________________________________________________________________________
[Mon 03/17/2003 05:39:54] End of Script [REM_Demo.cmd]
C:\GuardPost> |
- Output is displayed to STDOUT
Related .Mount/\Commands, #Constants,
$Functions, :Procedures
|
Resource |
|
Short Description |
|
.ShowComments |
|
Toggles the display of all lines that have been commented using .Rem. |
|
.HideComments |
|
Reverses the effect of .ShowComments (this is the default setting). |
|
K
E
Y |
Common Commands |
INTERNAL |
External |
/SWITCH |
Parameter |
Help text |
AddonTool |
|
Mounted Commands |
.Mount/\Command |
CmdShorthand |
#Constant |
$FUNCTION |
:Procedure |
!GuardNote |
|
Operating Systems |
NT/2K/XP/K3 |
NT Only |
NT/2K |
2K Only |
2K/XP |
XP Only |
XP/K3 |
K3 Only |
2K/XP/K3 |
|