if
の状態が:nbig
の2番目のバッチスクリプトで失敗しています。 (私はこれを各明細の後に@echo
を使って見つけました)。ただし、@echo
の内部のif
ステートメントのように、正常に実行されるとif
内のSET
ステートメントが成功します。これは非常に独特で、私は何が間違っているのか分かりません。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%
A正しく実行されているプログラムは、しかし、それエラーをtemp
の値を@echo
必要があります。
(脇:これは、カスタム倍と赤方偏移のプログラムを実行することです...)
を使用して、コードを簡素化することができますスタックをお読みくださいオーバーフロードキュメントページ[バッチファイルの変数](http://stackoverflow.com/documentation/batch-file/3528/)。 – Mofi