IF块崩溃?

时间:2016-03-17 14:12:37

标签: batch-file if-statement cmd syntax-error batch-processing

我为我的无能而道歉,因为我刚刚开始使用批处理,但是这个IF块每次运行时都会崩溃我的程序语法错误。我找不到错误,任何人都可以帮忙吗?

echo What is the scale of this conflict? (Determines length of game) 
echo 1. Small (Quick)
echo 2. Medium (Normal)
echo 3. Large (Extended)
SET /P difficulty="Type 1, 2, or 3, then press ENTER:"
IF %DIFF% == 3 (
set /a troops = %random% %%52 +45
set cities = 10
)
IF %DIFF% == 2 (
set /a troops = %random% %%32 +25
set cities = 6
)
IF %DIFF% == 1 (
set /a troops = %random% %%17 +10
set cities = 3
)

1 个答案:

答案 0 :(得分:0)

没有DIFF变量。您可能需要这个:

echo What is the scale of this conflict? (Determines length of game) 
echo 1. Small (Quick)
echo 2. Medium (Normal)
echo 3. Large (Extended)
SET /P difficulty="Type 1, 2, or 3, then press ENTER:"
IF %difficulty% == 3 (
set /a troops = %random% %%52 +45
set cities = 10
)
IF %difficulty% == 2 (
set /a troops = %random% %%32 +25
set cities = 6
)
IF %difficulty% == 1 (
set /a troops = %random% %%17 +10
set cities = 3
)