Reputation: 1
I m just trying to invoke a simple counter.To implement that I wrote the below script but the script is only giving me output as "Checking".
@echo off
echo checking
goto :check
:check
for /L %%a IN (1,1,4) do (
echo %%a
if %%a == 4 (
echo a is 4 now
echo congo
goto:eof
) else (
goto :check
)
Upvotes: 0
Views: 24
Reputation: 56155
a few Problems here:
1) you are missing a closing parantheses (very good visible when Code is properly intended)
2) any goto
breaks your block (a block is everything between (
and )
3) jumping ahead of your for
Loop will start it again, resulting in a endless Loop
4) no Need to goto :eof
, as for
will end of it's own when the Counter reaches 4
5) no need to goto <a label at the very next line>
This results in the following Code:
@echo off
echo checking
for /L %%a IN (1,1,4) do (
echo %%a
if %%a == 4 (
echo a is 4 now
echo congo
)
)
Upvotes: 1