2016-09-23 64 views
-1

我爲了好玩而批量製作遊戲。在遊戲中,我想參加一些遊戲,你可以試圖說服某人給你更多的錢用於任務或做某事。每次我嘗試這樣做時,都會收到一條消息,說明「失敗」不會被識別爲內部或外部命令,可操作程序或批處理文件。 我的代碼看起來像這樣錯誤地批評批處理組

@echo off 
SETLOCAL EnableDelayedExpansion 
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in   (1) do rem"') do (
set "DEL=%%a" 
) 
color 0a 
Echo King Redwood: So 2000? 
pause >nul 

echo. 
call :colorText 09 "1. 2500" 
echo. 
call :colorText 0e "2. 3000" 
echo. 
call :colorText 0c "3. 4000" 
echo. 
echo 4. 2000 
echo. 

set /p purs=Enter: 
if %purs% == 1 goto CheckB 
if %purs% == 2 goto CheckY 
if %purs% == 3 Goto CheckR 
if %purs% == 4 goto Convo 


:CheckB 
set bleu=%random:~-2,1% 
if %bleu% GTR 10 (
goto CheckB) 
if %bleu% LSS 0 (
goto CheckB) 
set num = 2 
set reward = 2500 
goto Res 

:Res 
if %bleu% GEQ %num% goto Succeed 
if NOT %bleu% GEQ %num% goto Fail 

:Succeed 
Echo OK 2500 will work. 
pause >nul 
goto end 

:Fail 
echo If 2000 isn't good enough for you, I'll just have someone else do it. 

:end 
exit 












:colorText 
echo off 
<nul set /p ".=%DEL%" > "%~2" 
findstr /v /a:%1 /R "^$" "%~2" nul 
del "%~2" > nul 2>&1i 

基本上,我只有它第一個成立。
我很喜歡任何類型的編碼。此外,:colorText是不是我的,我不很記得我從

回答

1

得到它當我跑了我:

C:\temp\Batches>if NOT 5 GEQ goto Fail 
'Fail' is not recognized as an internal or external command, operable program or batch file. 

正如你可以看到有什麼GEQgoto之間出現。您需要使用延遲擴展%num%!num!

+0

您在哪裏看到我需要添加此@FloatingKiwi – QuantumPrimus

+0

對不起,我在我的示例中修改了一下邏輯。我現在做了一個編輯。把這個放在你稱之爲'goto fail'的線上。 – FloatingKiwi

+0

我這樣做了,但是現在它從來沒有迴應失敗,即使我做了9次。你知道爲什麼會這樣嗎? @FloatingKiwi? – QuantumPrimus