China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-22 22:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Reference for Arrangement] The Role of Symbols under CMD/DOS StickyI View 153,266 Replies 216
Floor 16 Posted 2007-05-31 10:08 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Re qzwqzw

"Remember someone once said
It's just a useless tag
Comments are just its side effect"
The explanation about :: has been removed.

"Because when cmd detects an invalid character after a colon, it directly ignores the processing"
Tests show it doesn't matter if the "invalid" character is any character.

"The statement about the opposite number is easy to be misunderstood"
It has been revised. Previously, it was written like this to make it easy for others to understand, but it didn't describe its specific essential function.

"^ is bitwise XOR"
Revised.
btw, I want to ask, what's the difference between XOR and "different"?
Floor 17 Posted 2007-05-31 12:42 ·  中国 山西 运城 联通
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
It is found in testing that there is no so-called "invalid" character, and it can be any character.
-----------------------
:Of course, any character can follow the colon character
Because the cmd ignores the interpretation of invalid characters

How can we know this?
Define such a label ::errorlabel
Then try to goto ::errorlabel
If it can goto there, it means it is valid
Otherwise, it is invalid

Our comments naturally need to be marked with invalid labels
Otherwise, there may be conflicts with system-defined or our defined labels

The origin of :: actually has a long history
At first, it was because the rem command given by ms-dos could not directly use pipe and redirect symbols
And if you don't echo off, its code will be echoed during runtime
So someone took such a loophole

From these points, it can also be seen
Because there are many fewer preprocessing processes
The efficiency of using :: is higher than that of rem

Later, although many improvements were made to rem in cmd
But :: has spread because it is simple and easy to use and close to the comment mark of high-level languages
----------------------------------

I have never seen the term "bitwise XOR"
"XOR" means different from "OR"
Because the rule of OR is
0|0=0
0|1=1
1|0=1
1|1=1

And XOR is slightly different
0^0=0
0^1=1
1^0=1
1^1=0

[ Last edited by qzwqzw on 2007-5-31 at 12:46 PM ]
Floor 18 Posted 2007-05-31 15:10 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Thanks a lot for qzwqzw's clarification..

What I said: The following can be any character, which means that when making comments, all tags that are not called can be used as comments.

Regarding a label like goto ::errorlabel, it can never be reached by goto, so using :: is relatively reasonable.

Personal understanding is that because in goto, if there is a : in the label, then this colon is just a separator. There are several similar ones, such as,, :, (, and the characters after them are not interpreted.
If goto ::errorlabel, then the batch processing will think that it is going to a blank label, and a blank label cannot be constructed and make goto work.

Example: (call is used instead of goto for the sake of being able to return)
@echo off
call :hello;bat
call :hello,vbs
call :hello:asm
call :hello(java
call ::hello
pause&goto :eof

:hello
echo This is one line.
goto :eof
:
echo This is other line.


[ Last edited by lxmxn on 2007-5-31 at 08:15 PM ]
Floor 19 Posted 2007-05-31 19:08 ·  中国 山西 运城 联通
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
Your understanding of :: is more accurate than mine.
-----------------------------------------------------------------------

Analysis from the perspective of preprocessing

In the preprocessing process of goto and :label,
All special characters are all escaped or filtered.
And goto ::label is preprocessed into a goto empty label label.
The label is ignored by goto.

Because an empty label cannot be set with a jump mark,
So ::label will not work.
-----------------------------------------------------------------------

"Semicolon is an invalid character" is more accurately "Semicolons and other characters are delimiters (or delimiters) used to define tokens".
"The cmd ignores invalid labels" is more accurately "goto ignores the extra parameters after the empty label".

[ Last edited by qzwqzw on 2007-6-2 at 11:51 PM ]
Floor 20 Posted 2007-06-01 00:59 ·  中国 北京 中国科学院研究生院
银牌会员
★★★
Credits 1,187
Posts 555
Joined 2006-12-21 07:35
19-year member
UID 74129
Gender Male
Status Offline
Originally posted by lxmxn at 2007-5-30 22:24:
Re scriptor:

Well, thanks for the supplement, I'll add it in.

According to the explanation by qzwqze on floor 15, the annotation about :: has been removed.

[ Last edited by lxmxn on 2007-5-31 at 10:17 AM ]


Hehe
It's okay!

Floor 15#
It seems I know too little

Ashamed.
Floor 21 Posted 2007-06-01 01:50 ·  中国 湖北 武汉 电信
初级用户
★★
Credits 180
Posts 82
Joined 2007-01-11 23:02
19-year member
UID 76206
Gender Male
Status Offline
DDDDDD
好爱你哦。。。老婆
Floor 22 Posted 2007-06-01 02:16 ·  中国 广东 佛山 电信
高级用户
★★
我思故我在
Credits 512
Posts 228
Joined 2007-01-21 10:31
19-year member
UID 77225
Gender Male
Status Offline
What's missing is it!
我确实是只菜鸟,而且这里X人太多,所以我不敢装X。谁要再说我装X,我就XXOO他。
Floor 23 Posted 2007-06-04 15:08 ·  中国 安徽 合肥 联通
新手上路
Credits 18
Posts 9
Joined 2007-06-01 17:41
19-year member
UID 89988
Gender Male
Status Offline
Good stuff
Floor 24 Posted 2007-06-07 11:11 ·  中国 广东 广州 电信
初级用户
Credits 70
Posts 38
Joined 2007-05-23 07:20
19-year member
UID 89024
Gender Male
Status Offline
Not bad
Floor 25 Posted 2007-06-22 01:22 ·  中国 广东 汕头 潮阳区 电信
高级用户
★★★
DOS时空
Credits 713
Posts 348
Joined 2007-02-10 13:59
19-year member
UID 79169
Gender Male
Status Offline
Floor 26 Posted 2007-06-24 12:14 ·  中国 湖南 长沙 联通
初级用户
Credits 60
Posts 34
Joined 2007-04-24 02:13
19-year member
UID 86232
Gender Male
Status Offline
Don't understand much~
Floor 27 Posted 2007-06-26 11:11 ·  中国 山西 运城 联通
银牌会员
★★★
天的白色影子
Credits 2,343
Posts 636
Joined 2004-03-06 00:00
22-year member
UID 19350
Gender Male
Status Offline
%=
① Binary operators in set /a. For example, set /a a"%="b means assigning the remainder of a divided by b to a.
[Add " around %= to prevent % from being escaped, the same below.]
--------------------------------------------------------------------------
The description in [] is incorrect.
In the command line preprocessing of cmd,
The parsing of % occurs earlier than ".
That is, the priority of % is higher than ".
So the quotation marks cannot cancel the escape of %.

Here it should be explained that
It is okay to use a single % in the command line
set /a a%=b

In a batch script, double % need to be used
set /a a%%=b
Floor 28 Posted 2007-06-26 11:49 ·  中国 新疆 乌鲁木齐 电信
初级用户
Credits 24
Posts 9
Joined 2007-06-13 13:26
19-year member
UID 91175
Gender Male
Status Offline
Okay, collected it.
Floor 29 Posted 2007-06-26 13:01 ·  中国 新疆 乌鲁木齐 电信
初级用户
Credits 24
Posts 9
Joined 2007-06-13 13:26
19-year member
UID 91175
Gender Male
Status Offline
It would be great to have a post or article that gathers batch processing knowledge like this.
Floor 30 Posted 2007-06-26 13:12 ·  中国 广东 佛山 电信
初级用户
Credits 62
Posts 28
Joined 2006-03-14 02:15
20-year member
UID 51994
Status Offline
Thanks for sharing, I've bookmarked it!
Forum Jump: