En tant que débutant dans la programmation de fichiers batch, j'ai créé un fichier batch. Ci-dessous l'extrait de code -Comportement anormal du script batch dans If condition else
SET INDEX=1
SET CURRJOBS=10
REM TOTALJOBS and CURRJOBS are dynamic but to keep code here, i have put static values to them
SET TOTALJOBS=1000
IF [%CURRJOBS%] LSS [%TOTALJOBS%] (
IF [%INDEX%] GEQ [5] (
SET /A INDEX=0
)
ECHO Started at %date% %time% with %CURRJOBS% jobs>>%CURRDIR%\JobSubmit.log
REM Here is a call to another bat file with Index.
ECHO Finished at %date% %time% with %CURRJOBS% jobs>>%CURRDIR%\JobSubmit.log
SET /A INDEX+=1
GOTO START
)ELSE (
ECHO Finished at %date% %time% with %CURRJOBS% jobs>>%CURRDIR%\JobSubmit.log
)
Maintenant, ce code fonctionne parfois, parfois non. Cependant, il y a une erreur de syntaxe qui pourrait être une cause de comportement anormal. Existe-t-il un utilitaire IDE ou en ligne pour vérifier la syntaxe du fichier batch?
Quel est le problème avec le code ci-dessus?
Ok ... J'ai observé une chose de plus avec 'if-else'. Corrigez-moi si je me trompe. "' else' devrait commencer sans espaces après avoir fermé le crochet de 'if'." Y a-t-il un vérificateur de syntaxe pour le script batch? –