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-09-30 02:51
中国DOS联盟论坛 » DOS学习入门 & 精彩文章 (教学室) » What is the difference between `for %i` and `for %a`? View 5,109 Replies 22
Floor 16 Posted 2009-09-17 13:03 ·  马来西亚
初级用户
★
Credits 70
Posts 33
Joined 2009-09-15 13:28
17-year member
UID 152067
Gender Male
Status Offline
In the English 26 letters,
In FOR, they are all variables, and there is no difference.
Floor 17 Posted 2009-09-20 13:32 ·  中国 山西 太原 移动
初级用户
★
Credits 49
Posts 26
Joined 2007-09-11 15:38
19-year member
UID 97109
Gender Male
Status Offline
What does the following "echo %+/%,/%-" mean?

Originally posted by lxmxn at 2008-1-6 12:48 AM:

There are definitely more than 26 symbols:
for /f "tokens=1,3,4" %+ in ("hello world batch fans") do @echo %+/%,/%-



What does the following "echo %+/%,/%-" mean?
Floor 18 Posted 2009-10-17 14:26 ·  中国 湖北 武汉 电信
新手上路
★
Credits 8
Posts 3
Joined 2009-10-14 23:09
16-year member
UID 153086
Gender Male
Status Offline
Originally posted by zhxy9804 at 2008-11-11 13:47:
Can you explain the meaning of the code on the seventh floor? I don't understand it, thank you! :(


Code on the seventh floor
for /f "tokens=1,3,4" %+ in ("hello world batch fans") do @echo %+/%,/%-

Read "hello world batch fans", split into individual tokens according to the space (default) delimiter, take the 1st, 3rd, and 4th tokens, and assign them to %+ %, %- respectively (because according to ASCII code values, 43 corresponds to +, 44 corresponds to ,, 45 corresponds to -). So %+ is hello %, is batch %- is fans

The final result is hello/batch/fans
Floor 19 Posted 2009-10-17 18:20 ·  中国 山东 临沂 兰山区 电信
中级用户
★★
Credits 208
Posts 97
Joined 2006-12-28 22:08
19-year member
UID 74845
Gender Male
Status Offline
Floor 20 Posted 2009-10-25 09:06 ·  中国 黑龙江 哈尔滨 联通
新手上路
★
Credits 11
Posts 6
Joined 2009-10-20 14:32
16-year member
UID 153381
Gender Male
Status Offline
Floor 21 Posted 2009-11-04 23:18 ·  中国 安徽 合肥 电信
初级用户
★
Credits 55
Posts 39
Joined 2008-12-13 16:49
17-year member
UID 133761
Gender Male
Status Offline
Floor 22 Posted 2009-11-06 04:33 ·  韩国 Hanaro电信
新手上路
★
Credits 11
Posts 6
Joined 2009-11-04 18:50
16-year member
UID 154179
Gender Male
Status Offline
Floor 23 Posted 2009-11-10 01:02 ·  中国 北京 中国科学院研究生院
新手上路
★
Credits 14
Posts 9
Joined 2008-11-24 19:17
17-year member
UID 131988
Gender Male
Status Offline
Learned, it seems that it should be done in ascending order of ASCII. As for the statement that there are only 26 letters, I have also seen it, maybe it's a problem with different Windows versions.
Forum Jump: