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