I am reading lines from a text file. I need to ignore the first half and after a certain line is reached, assign the lines read into a variable. The 2nd if statement never fulfills even though the output shows that q has incremented from 0 to 1.
Code:
set q=0
for /f "tokens=*" %%a in (myfilename) do (
if "%%a" == "# My Trigger Text" (
set /A "q+=1"
set q :: Debug Statement 1
echo %%a
)
if %q% GTR 0 (
set /A "q+=1"
set q :: Debug Statement 2
echo %%a
[Other code will eventually go here; nothing right now]
)
:: set q :: Debug Statement 3
)
pause
Output with Debug Statement 3 commented out shows:
ECHO is off.
q=1
# My Trigger Text
Press any key to continue...
If I uncomment Debug Statement 3, the output is:
ECHO is off.
q=0
q=0
q=0
q=0
q=0
q=0
q=1
# My Trigger Text
q=1
q=1
q=1
q=1
q=1
q=1
q=1
Press any key to continue...
So q is getting incremented the first time when it hits the trigger text, but it is not evaluating q to be greater than 0 to get inside the functional loop.
Aucun commentaire:
Enregistrer un commentaire