| 1. |
Solve : How read a particular line from a text file?? |
|
Answer» Hi Friend, Code: [Select]@echo off Why not increment the count like this? Code: [Select]@echo off setlocal enabledelayedexpansion set count=0 for /f %%v in (test.txt) do ( set /a count=!count!+1 if !count!==3 echo %%v ) Quote from: Dias de verano on June 16, 2008, 06:50:06 AM Why not increment the count like this? No particular reason. The result is the same, so I suggest it's a matter of style rather than efficiency. Why do you ask? I was curious why you used found that call set /a %%count%% statement. Quote from: Dias de verano on June 16, 2008, 08:45:35 AM I was curious why you used found that call set /a %%count%% statement. Probably from deranged habit. In the OP case, delayed expansion was necessary, but sometimes other approaches create interesting results: Code: [Select]@echo off set count=0 for /f %%v in (test.txt) do ( call set /a count=%%count%%+1 call echo %%count%% ) The call to echo produces a running tally of the count variable. Without the call, results are less than stellar. If I could have, I'd have called the if statement, but it doesn't QUITE work. |
|