中国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-08-18 16:23
47,814 topics / 349,908 posts / today 1 new / 48,259 members
DOS疑难解答 & 问题讨论 (解答室) » The Dilemma of SET
Printable Version  4,006 / 9
Floor1 gmy Posted 2004-07-04 00:00
版主 Posts 392 Credits 1,113
SET a=1
SET b=2
SET c=a+b

In BASIC, the value of C would be 3, but batch processing can't do that.

I've tried ASET, XSET, STRINGS and none worked (they only support direct numeric operations)

Is there any other small tool that can solve "arithmetic operations between variables"?
Floor2 Climbing Posted 2004-07-05 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
If it is the DOS mode of Windows 2000/xp/2003, you can use:
set /a c=a+b

As for the pure DOS environment, you can use Horst's varset.
Floor3 gmy Posted 2004-07-05 00:00
版主 Posts 392 Credits 1,113
Thanks, going home to try it out.
Also, CLIMBING? It's the moderator of Wuyou! Long time no see!
Floor4 Wengier Posted 2004-07-06 00:00
系统支持 Posts 10,521 Credits 27,736
gmy, in fact, STRINGS can also be done, for example:

SET A=1
SET B=2
STRINGS C=ADD %A%,%B%
Floor5 gmy Posted 2004-07-09 00:00
版主 Posts 392 Credits 1,113
to Wengier

STRINGS C=ADD %A%,%B%

It doesn't seem to work. I tried. If it's:

STRINGS C=ADD 1,2

It's okay. STRINGS doesn't support variable forms (%X%)
Floor6 gmy Posted 2004-07-09 00:00
版主 Posts 392 Credits 1,113
### to Climbing

VARSET Success! Thank you! The specific steps are:

set a=1
set b=2
call var set c=%a%,%b%

Then press ENTER after SET
C=3
Floor7 Wengier Posted 2004-07-09 00:00
系统支持 Posts 10,521 Credits 27,736
gmy, who said STRINGS doesn't support variable form? I did an experiment before replying, and it proved that it's absolutely feasible before posting it. In fact, there is no question of whether STRINGS supports environment variables at all, but it depends on whether DOS supports it, because after entering the environment variable, DOS automatically converts the environment variable into its actual value and hands it to the program for use, either because the usage method is wrong. Note: I tested it under the pure MS-DOS 7.10 command line.
Floor8 Climbing Posted 2004-07-10 00:00
铂金会员 Posts 2,753 Credits 6,962 From 河北保定
STRINGS is what command? Forgive me for being ignorant, I'm seeing this command for the first time, and I've learned something new!

Is this command only usable under DOS 7.10? I didn't find this command in the DOS mode of 2003. Why does Microsoft keep changing things like this?

Also, I think varset is more universal because it can be used in any DOS environment.
Floor9 Wengier Posted 2004-07-10 00:00
系统支持 Posts 10,521 Credits 27,736
In fact, both Strings and Varset are external tools, not built-in with DOS. It's just that Varset was written by Horst, while Strings was written by Dunglas and has more functions. Both can be downloaded in the "Script Tools" section of the website. Since the LZ mentioned Strings in the post, I'll explain that Strings can do it (Varset can certainly do it too).
Floor10 fairsky007 Posted 2010-09-01 22:50
初级用户 Posts 8 Credits 21
Strings are indeed great things!!!
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023