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-20 06:36
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Understanding the interception function of variable characters in CMD View 22,968 Replies 100
Floor 46 Posted 2007-06-17 13:30 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
RE bd123456789:

1. The effect of pause>nul is the same as the standalone pause command, except that it doesn't display the "Press any key to continue..." message. Here is the function of >nul. For a specific analysis, you can search for relevant discussion posts in the forum.

2. Refer to the following two links:
Detailed Explanation of Variable Delay (Recommended for Newcomers)
http://www.cn-dos.net/forum/viewthread.php?tid=28273&fpage=1

Under what circumstances should variable delay be used?
http://www.cn-dos.net/forum/viewthread.php?tid=20733&fpage=1
Floor 47 Posted 2007-06-24 07:08 ·  中国 浙江 嘉兴 海宁市 电信
中级用户
★★
Credits 360
Posts 216
Joined 2007-05-29 17:41
19-year member
UID 89677
Gender Male
Status Offline
Hehe, practical
Thank you very much!
Floor 48 Posted 2007-06-24 20:03 ·  中国 上海 东方有线
中级用户
★★
Credits 218
Posts 86
Joined 2006-08-10 10:45
19-year member
UID 60205
Gender Male
Status Offline
This thing is great. Already bookmarked. Thanks, LZ.
Floor 49 Posted 2007-06-24 23:29 ·  中国 上海 电信
中级用户
★★
Credits 231
Posts 112
Joined 2007-06-19 20:44
19-year member
UID 91827
Gender Male
Status Offline
It's of great help to newbies~
Floor 50 Posted 2007-09-28 11:54 ·  中国 山西 太原 万柏林区 电信
初级用户
Credits 49
Posts 26
Joined 2007-09-11 15:38
18-year member
UID 97109
Gender Male
Status Offline
Floor 51 Posted 2007-10-09 02:43 ·  中国 湖南 益阳 电信
新手上路
Credits 17
Posts 10
Joined 2007-01-22 04:52
19-year member
UID 77300
Gender Male
Status Offline
The LZ is really a good guiding teacher. Write more... (Don't beat me... Hehe)
Floor 52 Posted 2007-10-09 10:19 ·  中国 广东 广州 海珠区 电信
初级用户
Credits 81
Posts 35
Joined 2006-10-16 22:11
19-year member
UID 65994
Status Offline
Got it. Thanks lxmxn!!!
Floor 53 Posted 2007-10-20 02:05 ·  中国 河北 廊坊 联通
初级用户
Credits 42
Posts 21
Joined 2007-10-03 03:11
18-year member
UID 98806
Gender Male
Status Offline
It can also be passed like this!!!
Floor 54 Posted 2007-10-31 18:06 ·  中国 上海 东方有线
新手上路
Credits 16
Posts 8
Joined 2007-10-31 17:41
18-year member
UID 101308
Gender Male
Status Offline
Please allow me to raise a very basic question.
Moderator, after reading many of your posts, I can only say two words: "Admiration".

I have just started to get in touch with this kind of thing and there are many things I don't understand. For example, I just demonstrated the one you posted earlier, but I can't understand what it means. I hope you don't laugh at me.

I really hope to get everyone's help in future studies.

Thank you
Floor 55 Posted 2007-10-31 18:26 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by fengjian at 2007-10-31 18:06:
Please allow me to post a very basic question
Moderator, after reading many of your posts, I just have two words in my heart: "Admiration"

I have just started to get in touch with this kind of thing, and there are many things I don't understand. For example, the one you just posted, I perform...

In fact, this variable interception is equivalent to the substr function in other languages, which can intercept a substring at a specified position in a string.

For example, if the first two characters of a string are what you want, then you can use variable interception to get the string you want.

For example
set string=cn.sina.com
set new=%string:~0,2%
Then the value of %new% is the first two characters of %string%, that is, "cn".
Floor 56 Posted 2007-11-04 00:46 ·  中国 上海 静安区 中移铁通
初级用户
Credits 48
Posts 23
Joined 2007-10-24 09:46
18-year member
UID 100622
Gender Male
Status Offline
In a `for /l` loop in Windows batch scripting, the syntax `(start, step, end)` is used. For `(1,3,15)`: the `start` is 1, the `step` is 3, and the `end` is 15. It will iterate starting at 1, then add 3 each time, and stop when it reaches or exceeds 15. So it will generate values like 1, 4, 7, 10, 13, 16 (but 16 is over 15 so stops at 13). For `(1,4,15)`: the `start` is 1, the `step` is 4, and the `end` is 15. It will iterate starting at 1, then add 4 each time, and stop when it reaches or exceeds 15. So it will generate values like 1, 5, 9, 13, 17 (but 17 is over 15 so stops at 13). The first loop variable `%%a` takes on these values generated by the first `for /l` loop, and the second loop variable `%%b` takes on the values generated by the second `for /l` loop, and then each time it calls the `:printf` subroutine with `%%a` and `%%b` as arguments.
Floor 57 Posted 2007-11-04 00:49 ·  中国 上海 静安区 中移铁通
初级用户
Credits 48
Posts 23
Joined 2007-10-24 09:46
18-year member
UID 100622
Gender Male
Status Offline
Continuing from the previous part, it seems that the FOR below doesn't use the value of this variable? I don't understand it.
Floor 58 Posted 2007-11-04 09:59 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
RE z310394543:

1、(1,3,15) is used to control the variable %%i in the for loop, representing an arithmetic sequence, that is, a sequence starting from 1, increasing by a step of 3, but the maximum number is 15.

2、The variable var is used in the call sub - procedure, you can search for examples of call usage in the forum.
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
z310394543 +2 2007-11-04 20:57
Floor 59 Posted 2007-11-04 20:58 ·  中国 上海 静安区 中移铁通
初级用户
Credits 48
Posts 23
Joined 2007-10-24 09:46
18-year member
UID 100622
Gender Male
Status Offline
The efficiency of the moderator is really high
Floor 60 Posted 2007-11-09 20:10 ·  中国 江苏 徐州 电信
新手上路
Credits 6
Posts 3
Joined 2007-10-23 20:57
18-year member
UID 100583
Gender Male
Status Offline
It simply didn't explain the usage. Those who know still know, and those who don't still don't.
Forum Jump: