0
我的批處理腳本在第二個if
狀態:nbig
中失敗。 (我發現每個陳述後都使用@echo
)。但是,if
中的SET
語句如果正常運行,則會成功,因爲if
語句中的@echo
也是如此。這是非常奇特的,我看不出我做錯了什麼。批處理腳本在IF語句中失敗
我的代碼是在這裏:
:: Set the day and night values
set /A nighttemp = 2700
set /A daytemp = 6500
:: Set Transition Duration
set /A transitionduration = 60
:: Set times in minutes from midnight
set /A tnight = 1380
set /A tday = 480
For /f "tokens=1-4 delims=/:." %%a in ("%TIME%") do (
SET /A HH24=%%a
SET /A MI=%%b
SET /A SS=%%c
SET /A FF=%%d
)
SET /A mins = %HH24%*60 + %MI%
SET /A tdaywindow = %tday% + 60
SET /A tnightwindow = %tnight% + 60
if %tnight% GEQ %tday% (GOTO NBIG)
if %tnight% LSS %tday% (GOTO DBIG)
pause
:NBIG
if %mins% LSS %tday% (SET /A temp = %nighttemp%)
if %mins% LSS %tdaywindow% (SET /A temp = (%daytemp% - %nighttemp%)*((%mins% - %tday%)/60) + %nighttemp%)
if %mins% LSS %tnight%(SET /A temp = %daytemp%)
if %mins% LSS %tnightwindow%(SET /A temp = (%nighttemp% - %daytemp%)*((%mins% - %tnight%)/60) + %daytemp%)
GOTO ENDING
:DBIG
if %mins% LSS %tnight%(SET /A temp = %daytemp%)
if %mins% LSS %tnightwindow% (SET /A temp = (%nighttemp% - %daytemp%)*((%mins% - %tnight%)/60) + %daytemp%)
if %mins% LSS %tday% (SET /A temp = %nighttemp%)
if %mins% LSS %tdaywindow% (SET /A temp = (%daytemp% - %nighttemp%)*((%mins% - %tday%)/60) + %nighttemp%)
GOTO ENDING
:ENDING
@echo %temp%
pause
::%~dp0\redshift.exe -O %temp%
一個運行正常的程序應該@echo
的temp
價值,但它的錯誤。
(旁白:這是運行與自定義時間紅移程序...)
請閱讀棧簡化代碼溢出文檔頁面[批處理文件中的變量](http://stackoverflow.com/documentation/batch-file/3528/)。 – Mofi