批处理变量方程 [英] Batch variable equations

查看:107
本文介绍了批处理变量方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要像这样的变量相减或相加的帮助
@echo关闭
设置var = 5
回声%var%
暂停
回声___________________________________________
设置/a%var%+1
回声%var%
暂停
您能帮我吗?

I need help with subtracting or adding with variables kind of like this
@echo off
set var=5
echo %var%
pause
echo ___________________________________________
set /a %var% +1
echo %var%
Pause
Can you help me?

推荐答案

可能是我在猜测问题,但我认为它不起作用".
试试这个
Probably, I''m guessing at the problem but I assume "it doesn''t work".
Try this
@echo off

echo Testing Set /P and Set /A
set /p NUM1=Enter a number :
set /p NUM2=Enter another number :

set /a RESULT=NUM1+NUM2
echo %NUM1% + %NUM2% = %RESULT%

REM your stuff corrected
set var=5
echo %var%
set /a var=var+1
echo %var%

pause


除了Alan N的正确答案:

Rob van der Woude撰写的精彩的批处理脚本, http://www.robvanderwoude.com [ http://www.robvanderwoude.com/allhelp.php [ http://www.robvanderwoude.com/files/allhelp_nt.txt [
In addition to a correct answer by Alan N:

This wonderful batch script by Rob van der Woude, http://www.robvanderwoude.com[^], with improvements by Johan Parlevliet build a complete help on all batch commands on your system:
http://www.robvanderwoude.com/allhelp.php[^],
http://www.robvanderwoude.com/files/allhelp_nt.txt[^].

Good luck,
—SA


这篇关于批处理变量方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆