中国DOS联盟论坛

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-09-25 10:47
47,813 topics / 349,918 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » [Reference for Arrangement] The Role of Symbols under CMD/DOS
Printable Version  159,590 / 216
Floor16 lxmxn Posted 2007-05-31 10:08
版主 Posts 4,938 Credits 11,386
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"?
Floor17 qzwqzw Posted 2007-05-31 12:42
银牌会员 Posts 636 Credits 2,343
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 ]
Floor18 lxmxn Posted 2007-05-31 15:10
版主 Posts 4,938 Credits 11,386
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)


[ Last edited by lxmxn on 2007-5-31 at 08:15 PM ]
Floor19 qzwqzw Posted 2007-05-31 19:08
银牌会员 Posts 636 Credits 2,343
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 ]
Floor20 scriptor Posted 2007-06-01 00:59
银牌会员 Posts 555 Credits 1,187
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.
Floor21 dinfli Posted 2007-06-01 01:50
初级用户 Posts 82 Credits 180
DDDDDD
Floor22 qinbuer Posted 2007-06-01 02:16
高级用户 Posts 228 Credits 512
What's missing is it!
Floor23 wj12390 Posted 2007-06-04 15:08
新手上路 Posts 9 Credits 18
Good stuff
Floor24 Li103Z Posted 2007-06-07 11:11
初级用户 Posts 38 Credits 70
Not bad
Floor25 haiou327 Posted 2007-06-22 01:22
高级用户 Posts 348 Credits 713
Collected.
Floor26 wgx1688 Posted 2007-06-24 12:14
初级用户 Posts 34 Credits 60
Don't understand much~
Floor27 qzwqzw Posted 2007-06-26 11:11
银牌会员 Posts 636 Credits 2,343
%=
① 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
Floor28 wl48693752 Posted 2007-06-26 11:49
初级用户 Posts 9 Credits 24
Okay, collected it.
Floor29 wl48693752 Posted 2007-06-26 13:01
初级用户 Posts 9 Credits 24
It would be great to have a post or article that gathers batch processing knowledge like this.
Floor30 Lick Posted 2007-06-26 13:12
初级用户 Posts 28 Credits 62
Thanks for sharing, I've bookmarked it!
Prev  1 2 3 4 5 … 15  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023