應該發生的是您輸入的數字在1到1,048,567之間。該程序檢查您的輸入是否實際上是介於1和1,048,567之間的數字。如果你的輸入是一個有效的數字,那麼它將繼續到下一個代碼。如果輸入無效,則會顯示一條消息,說明該消息無效,然後再循環並再次請求輸入。 然而,當我運行這個時,我輸入了任何內容,即使輸入了一個介於1和1,048,567之間的數字,它也會顯示輸入無效。我的.bat腳本中的if語句沒有按預期工作
代碼:
:setup
@echo off
title Pokemon Shiny Sim
set delay = nul
set count = 0
set chance = 4096
:settings
:setChance
cls
echo Set shiny chance (1 in x). Range: (1-1,048,567)
echo Leave blank for 1 in 4096.
set /p chance = Input:
set /a chance = %chance%+0
if %chance% GEQ 1 (
if %chance% LEQ 1048567 (
goto setDelay
)
)
echo Invalid Input.
pause
goto setChance
:setDelay
cls
echo Set delay between attempts in seconds. Range: (1-60).
echo Leave blank for no delay.
set /p delay = Input:
set /a delay = %delay%+0
if %delay% == nul (
goto loopStart
)
if %delay% GEQ 1 (
if %delay% LEQ 60 (
cls
goto loopStart
)
)
echo Invalid Input.
pause
goto settings
:loopStart
set /a count = %count%+1
set /a rand = %random% %% %chance%+1
if %rand% == 1 (
echo Attempt: %count% | Shiny: Yes!
pause
)
else (
echo Attempt: %count% | Shiny: No
)
goto loopStart
你正在設置一個變量:你正在設置一個變量'chance'(注意這個空格!)刪除等號之間的空格 – SteveFest
另外,你在迴避'''管道'|'而不會逃逸。使用'^ |'而不是'|' – SteveFest
@SteveFest感謝提示錯誤設置變量和回顯| |。儘管原來的問題仍然存在。 –