0

Can someone please tell me why my code is not working.

FOR /L %%I IN (1,1,2) DO (
set val=D:val.txt
for /f "tokens=1 delims=    " %%a in (%val%) do set chaine1=%%a

SET pre_com=%chaine1: =%
echo %chaine1%
set /a  com=%pre_com%
echo "la valeur est : %com% " >>  val.txt >&1

)
Mar
  • 419
  • 1
  • 7
  • 19
  • 1
    classic [delayed expansion trap](https://stackoverflow.com/questions/30282784/variables-are-not-behaving-as-expected/30284028#30284028). I'm not closing this question as a duplicate for now, because you may have more issues with it. Please update and confirm/decline/explain further issues. – Stephan Jan 08 '20 at 16:06
  • I already checked these topis but in vain. I just wanna execute what's inside the first loop twice and get the value of %com% each time the loop is executed. – Mar Jan 08 '20 at 16:12
  • I find the top [here](https://stackoverflow.com/questions/6679907/how-do-setlocal-and-enabledelayedexpansion-work) to be well written about delayed expansion. I personally hate the !syntax! so I use [this](https://www.dostips.com/DtTutoFunctions.php) method of batch functions instead. (also, it pre-existed the delayed expansion stuff) – Señor CMasMas Jan 08 '20 at 16:14
  • Also, `D:val.txt` is not valid, try `D:\val.txt` instead. – Compo Jan 08 '20 at 16:46

0 Answers0