Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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 - Fatal编程技术网

Batch file 批处理变量的问题

Batch file 批处理变量的问题,batch-file,Batch File,我无法将未设置的变量设置为变量。 它不在块中,并且setlocal enabledelayedexpansion未启用,因为我喜欢使用感叹号 cls IF "%croptomatoes%"=="" set "%croptomatoes%"=="0" echo Your Hunger- %hunger%/%maxhunger% echo 1) Eat 6 Tomatoes - 1 Hunger - You have %croptomatoes% 将set语法与变量展开和比较运算符混淆。要设置变量

我无法将未设置的变量设置为变量。 它不在块中,并且setlocal enabledelayedexpansion未启用,因为我喜欢使用感叹号

cls
IF "%croptomatoes%"=="" set "%croptomatoes%"=="0"
echo Your Hunger- %hunger%/%maxhunger%
echo 1) Eat 6 Tomatoes - 1 Hunger - You have %croptomatoes%

set
语法与变量展开和比较运算符混淆。要设置变量,请执行以下操作:

set croptomatoes=0

如果您将来感到困惑,请记住,在WIndows中,您通常可以将
/?
传递给这些命令。因此,
set/?
将为您提供有关用法的信息。与
if
for
和其他相同。