2011-11-09 48 views
0

此批處理腳本始終給出答案「您可以設置0」而不是其他選項。 我在這裏做錯了什麼?不能在批處理腳本中有條件地更改變量

set /a foodcalc=0 
set /a dish=0 
set /a food1=1 
set /a food2=2  
set /a food3=3  
set /a food4=4  
SET /a foodcalc=4*%random%/32768+1  
IF foodcalc==1 set /a dish food1  
IF foodcalc==2 set /a dish food2  
IF foodcalc==3 set /a dish food3  
IF foodcalc==4 set /a dish food4 
echo You make some %dish%.  
ping localhost -n 3 >nul  
goto actualgame 

回答

1
IF %foodcalc%==1 set /a dish=food1 
IF %foodcalc%==2 set /a dish=food2 
IF %foodcalc%==3 set /a dish=food3 
IF %foodcalc%==4 set /a dish=food4 
+0

哦,對了!這是=我忘記了,謝謝! – Zimano

2

需要用%來指回變量的內容,這樣

 if %foodcalc%==1 echo one! 
相關問題