如標題所示,我的批處理腳本不工作,我知道這個錯誤發生在「REM BUCKS」之後,我也看到了文字「0在這個時候是意外的,」在退出之前,你們可以看看有什麼問題嗎?也許提供一個解決方案?我需要這個代碼用於我的遊戲。我的CMD批處理腳本不工作(此時0意外)。
這個腳本是一個得分腳本,我通過添加「SET的」
根據模擬它「REM SCORE」將設置來獲得0,如果獲得變量是一個負數。
我不能給你完整的腳本怎麼一回事,因爲它如此巨大
這裏是代碼:
SETLOCAL
set stage=add
set r=10
set dif=3
set timer=30
set w=2
set cash=6
REM BUCKS
if %stage%==cha (
set st=10
REM SCORE
call :calculator %r%*10*%dif%*%st%-%w%*%timer%
timeout 5 > NUL
set earn=%val%
if %earn% LSS 0 set earn=0
set /a cash=%cash% + %val%
goto :EOF
)
if %stage%==0 goto :EOF
if %stage%==add set st=3
if %stage%==sub set st=4
if %stage%==mul set st=5
call :calculator %r%*10*%dif%*%st%-(%timer%*%w%)
set earn=%val%
if %earn% LSS 0 (
set earn=0
)
set /a cash=%cash% + %val%
pause
exit
goto :EOF
:calculator
>"%temp%\VBS.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject") : Wscript.echo (%*)
for /f "delims=" %%a in ('cscript /nologo "%temp%\VBS.vbs"') do set "val=%%a"
del "%temp%\VBS.vbs"
goto :EOF
THX閱讀
變量擴展。也許[這](http://stackoverflow.com/a/30177832/2861476)可以幫助 –