在批处理中

时间:2016-09-23 19:11:17

标签: batch-file

我正在批量制作游戏,只是为了好玩。在游戏中,我希望参与某些游戏,你可以试图说服别人给你更多钱来完成任务或做点什么。每当我尝试这样做时,我都会收到一条消息,说“失败”。不被识别为内部或外部命令,可操作程序或批处理文件。 我的代码看起来像这样

@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 个答案:

答案 0 :(得分: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!

来使用延迟展开