Finally, i got my variation of documentation to work without any extra character:
- insert a line containing "%[%" to start a comment, and
- insert a line containing "%]%" to end a comment
- a multilinecomment must be a single token: per line a token immediately followed by an "^" at the end of the line, or
- the comment may be a single space, or single/multiple ":" followed by a single string, immediately followed by an "^" at the end of that line.
The string is allowed to contain any character except: 0x00 (NUL), 0x0A (NL), 0x1A (SUB), 0x22 (").
You could also use this method to comment single parameters (as this method is an advanced method of this, see my upper posts):
Code: Select all
@echo off
cls
setlocal
set LF=^
setlocal disableDelayedExpansion
set ^"\n=^^^%LF%%LF%^%LF%%LF%^<nul ^^^"
set ^"[=%%~#^<nul ^^^%LF%%LF%^<nul ^^^"
set ^"]=^<nul^^^%LF%%LF%^%LF%%LF%^<nul ^^^"
endlocal & (
@echo on
for %%# in ("") do set macro=^(cmd1 arg11 arg21 arg31 arg41%\n%
cmd2%[%___comment_cmd2_______%]%
arg 1%[% "comment argument 1 is no numeric equivalent of a handle"%]%
arg 2%[%_"comment argument 2 is no numeric equivalent of a handle"%]%
arg3 arg4 arg5%\n%
%[%
comment_1^
"comment 2"^
::"comment 3 chars in {0x00, ..., 0xFF} \ {0x00, 0x0A, 0x1A, 0x22}"^
%]%
cmd3 arg31 arg32 arg33%\n%
^)
@echo off
)
set macro > macro.txt
endlocal
goto :eof
Tested on WinXP.
penpen
Edit1:
Changed the text above a little bit and added the single parameter commenting.
Added a tilde character prior to the last doublequte in the definition of the environment variables "\n", "[", and "]" to avoid unfinished strings (could be in problem in macros that define macros).
Added the expansion of nothing (for %%#, %%~#) to avoid misinterpretations of single digits as a numeric equivalent of a handle.
Added the single argument comments (cmd2).
Encapsulated the environment variables "\n", "[", and "]" within setlocal blocks to not corrupt these variables within an actual environment.