![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-12 13:14 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Blank lines and labels (that is, lines starting with : or ::) cannot be used consecutively at the same time inside () |
| Printable Version 1,333 / 6 |
| Floor1 Hanyeguxing | Posted 2009-09-03 01:29 |
| 银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂 | |
|
Inside (), blank lines and labels (that is, lines starting with : or ::) cannot be used consecutively at the same time
Running the following batch file gives the error “The command syntax is incorrect”; if you remove the blank line or the :: line, it runs normally: Running the following batch file gives the error “The command syntax is incorrect”; if you remove the blank line or the : line, it runs normally: Why is that? [ Last edited by Hanyeguxing on 2009-9-3 at 02:50 ] |
|
| Floor2 Hanyeguxing | Posted 2009-09-03 01:54 |
| 银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂 | |
| Floor3 netbenton | Posted 2009-09-03 02:08 |
| 银牌会员 Posts 752 Credits 1,916 From 广西 | |
|
:labels, when placed inside compound code blocks, are inherently meaningless to batch files,
so it should be normal that they can't run; if they can run, that would instead be a bug in cmd |
|
| Floor4 Hanyeguxing | Posted 2009-09-03 02:12 |
| 银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂 | |
Originally posted by netbenton at 2009-9-3 02:08: But without a blank line, it can run. It's just that labels and blank lines can't be used inside () at the same time; used separately, either one still works. Besides, the command-line syntax doesn't specify anything like that either. [ Last edited by Hanyeguxing on 2009-9-3 at 02:49 ] |
|
| Floor5 tireless | Posted 2009-09-03 08:42 |
| 银牌会员 Posts 1,122 Credits 2,025 | |
|
It just isn't allowed to be used that way, I guess, so it gives the prompt “The command syntax is incorrect.”
I tried AutoHotkey too, and it can't be used this way either. Code: After running it, the prompt is: Error: A label must not point to the end of a block. For loops, use Continue vs. Goto. |
|
| Floor6 plp626 | Posted 2009-09-09 12:34 |
| 银牌会员 Posts 1,020 Credits 2,278 | |
|
I've been working with batch files for ages, but actually there are still a lot of things about cmd preprocessing that I don't dare dig into deeply, just like pointers and memory management in C; subconsciously I always avoid them...
But it's exactly these so-called “bugs” that make cmd more interesting in an invisible way. If used properly, they can achieve a lot of strange functions. Just like malformed directories, we're happy to accept them too. |
|
| Floor7 todayambition | Posted 2010-04-14 22:51 |
| 新手上路 Posts 9 Credits 14 | |
|
It really is like that too... can't figure it out
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |