Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理文件变量问题_Batch File_Batch Processing - Fatal编程技术网

Batch file 批处理文件变量问题

Batch file 批处理文件变量问题,batch-file,batch-processing,Batch File,Batch Processing,我在批处理文件中传输变量时遇到问题 这是我所拥有的一个粗略的例子: @echo off setlocal enabledelayedexpansion :one set variableone=outputone set variabletwo=outputtwo set variablethree=outputthree goto two :two set /a variable%variableone%four=numberone set /a variable%variabletwo%

我在批处理文件中传输变量时遇到问题

这是我所拥有的一个粗略的例子:

@echo off
setlocal enabledelayedexpansion

:one
set variableone=outputone
set variabletwo=outputtwo
set variablethree=outputthree
goto two

:two
set /a variable%variableone%four=numberone
set /a variable%variabletwo%five=numbertwo
set /a variable%variablethree%six=numberthree
goto three

:three
set /a variable%variableone%four+=(2*(!variable%variabletwo%five!-!!variable%variablethree%six!)
echo !variable%variableone%four!
exit

它比这个长得多,这只是它实际情况的简化版本,然而,标签中的变量“:three”不会向下传递,因此变量最终为空,从而使方程也为空。有办法解决这个问题吗

很难看到你在做什么

在下面的代码中,我用值替换了变量名
NUMBER*

我还添加了缺少的右括号,我想知道两个成功的括号

现在对我来说,被回响的是-8,等于14+(2*(25-36))


所以-对我有用

是的,这是奇怪的部分。在我的实际文件中,当我手动输入%variable2%和%variablethree%作为等式,输入%variableone%作为最后一行时,它工作得很好,但当我将其更改为变量时,它找不到它,所以我逐字查看了整个内容,尤其是变量本身,多次试图找到问题的根源,但我还没有找到它,但我知道它肯定在某个地方。在对我的文件进行了多次搜索后,我最终发现问题只是其中一个变量中的一个额外空间。感谢您的回复。要避免此类问题,请使用
设置“var=val”
@ECHO OFF
setlocal enabledelayedexpansion

:one
set variableone=outputone
set variabletwo=outputtwo
set variablethree=outputthree
goto two

:two
set /a variable%variableone%four=numberone
set /a variable%variabletwo%five=numbertwo
set /a variable%variablethree%six=numberthree
set /a variable%variableone%four=14
set /a variable%variabletwo%five=25
set /a variable%variablethree%six=36
goto three

:three
set /a variable%variableone%four+=(2*(!variable%variabletwo%five!-!!variable%variablethree%six!))
echo !variable%variableone%four!
set var