Windows批处理脚本中的代码块注解语法

pnwntuvh  于 2023-11-21  发布在  Windows
关注(0)|答案(4)|浏览(230)

在Windows批处理脚本中有没有多行代码块注解的语法?我知道REM::是逐行注解,但是注解一个代码块效率不高。
我正在寻找像下面的PHP块注解样式:

  1. /*
  2. This is multi-lines
  3. block comment
  4. */

字符串

lc8prwob

lc8prwob1#

我认为,这可以达到目的,

  1. goto:skip1
  2. echo This line should not get executed
  3. format c: & echo nor this line
  4. :skip1

字符串

trnvg8h3

trnvg8h32#

你可以用这个看起来更好的技巧...

  1. @echo off
  2. setlocal
  3. set comment=goto endcomment
  4. echo This line is executed
  5. %comment%
  6. echo These lines
  7. echo are commented out...
  8. :endcomment
  9. echo The next line to execute
  10. %comment%
  11. You may place here
  12. %$#"#% anything you want.... &!>|<()
  13. :endcomment
  14. echo End of example

字符串

展开查看全部
pzfprimi

pzfprimi3#

在批处理脚本中没有这样的东西。
(gotos excluded.)

shyt4zoc

shyt4zoc4#

没有那些讨厌的goto s、rem s和::的多行注解

  1. @break || (
  2. 1 line
  3. 2 line
  4. 3 line
  5. 4 line
  6. 5 line
  7. ...
  8. )

字符串

EDIT:由于前面的示例不起作用,您可以创建一个宏

  1. set "[:=goto :]%%"
  2. set "[=rem/||(" & set "]=)"
  1. %[:%
  2. multiline
  3. comment
  4. %:]%

的数据
(Not在for循环中工作)

展开查看全部

相关问题