2016-03-17 32 views
-1

我對我的無能表示歉意,因爲我剛剛開始使用批處理,但此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 
) 

回答

0

沒有DIFF variable.May是你需要這樣的:

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 
) 
+0

這個工作!謝謝,我覺得我忽略了那樣簡單的事情:) – g00t