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-30 01:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Trick] Swap the values of two variables without using a temporary variable View 8,153 Replies 20
Floor 16 Posted 2007-01-27 23:40 ·  中国 辽宁 大连 联通
初级用户
Alpha
Credits 46
Posts 21
Joined 2007-01-27 02:21
19-year member
UID 77790
Gender Male
Status Offline
About the algorithm of +-:

I did this before, but, let's continue to think with cups. Even if the two liquids are incompatible, but to pour the liquids from the two cups into one cup, then you can only pour at most half a cup (based on the upper limit for safety consideration, don't say the case where one cup has only the bottom and the other is almost full), otherwise an error will occur due to overflow!!
Impossible's Nothing!
Floor 17 Posted 2007-01-28 11:47 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Originally posted by pengfei at 2007-1-25 23:03:
The use of call %%var1%% by user lxmxn actually does not expand, which is another usage of variable delay like!var!. Therefore, variable exchange cannot be achieved.


  What I want to express is exactly this kind of invalid example.
Floor 18 Posted 2007-01-29 00:42 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Uh, let me say something off-topic. This thing is strongly recommended to be added to the wiki!

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 19 Posted 2007-01-29 02:19 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
Brother est is right, the idea of putting it on Wiki is good. Brother lxmxn pointed out the variable delay. In variable replacement in the script, prevent using delay (such as call delay and!var! delay).
业精于勤而荒于嬉,形成于思而毁于随。
Floor 20 Posted 2008-05-11 09:21 ·  中国 江西 上饶 广信区 电信
初级用户
Credits 29
Posts 29
Joined 2008-05-07 22:34
18-year member
UID 118049
Gender Male
Status Offline
Hehe, learned a little more again
Floor 21 Posted 2008-12-02 12:12 ·  中国 天津 联通
初级用户
Credits 24
Posts 11
Joined 2008-11-22 21:08
17-year member
UID 131788
Gender Male
Status Offline
Hehe, it cleverly uses the principle of preprocessing in batch processing. This is also one of the differences between interpreters and compilers. C and C++ have to use temporary variables to complete this exchange.
Forum Jump: