- Jul
- 530
- 10
First off: Why is the second loop's first value 4 and not 1? Why is it not re-initialized as part of the do?
Second off: Why is enddo an unknown command? I literally copied the same code
If I change the if them to use gotos instead of parens, this error goes away.
Stuff like this is why I got into the 25 year habit of never using parens with if statements, which resulted in some ugly code.
``
Second off: Why is enddo an unknown command? I literally copied the same code
If I change the if them to use gotos instead of parens, this error goes away.
Stuff like this is why I got into the 25 year habit of never using parens with if statements, which resulted in some ugly code.
Code:
@Echo off
set num_seconds=3
do second = 1 to %num_seconds% by 1
echo first loop: %second%
delay 1
enddo
if (0 == 1) (
delay %num_seconds%
) else (
do secondagain = 1 to %num_seconds% by 1
echo second loop: %secondagain%
*delay 1
enddo
)
<12:36p> <9%> C:\bat>test-tcc-bug-enddo.bat
first loop: 1
first loop: 2
first loop: 3
second loop: 4
Unknown command: 'enddo'