x2.bat outputs %f, and x3.bat doesn't. Why?
C:\>type x2.bat <ENTER>
for %%f in (a b) do (
echo %%f
echo tw
)
C:\>x2 <ENTER>
C:\>for %f in (a b) do (
echo %f
echo tw
)
C:\>(
echo a
echo tw
)
a
tw
C:\>(
echo b
echo tw
)
b
tw
C:\>
C:\>type x3.bat <ENTER>
for %%f in (a b) do (
echo %%f
)
C:\>x3 <ENTER>
C:\>for %f in (a b) do (echo %f )
C:\>(echo a )
a
C:\>(echo b )
b
C:\>
---
why does this FOR statement output %f and this one doesn't?
Moderator: DosItHelp
Re: why does this FOR statement output %f and this one doesn
Both outputs look fine to me. They each echo a and b which corresponds to %f.
Dave Benham
Dave Benham
Re: why does this FOR statement output %f and this one doesn
dbenham wrote::? Both outputs look fine to me. They each echo a and b which corresponds to %f.
Dave Benham
x2.bat has an extra iteration that x3.bat doesn't have, look at x2.bat's output before the iteration that echos 'a'. I'd like to know what's happening there. Why that is.
Re: why does this FOR statement output %f and this one doesn
oh my mistake, I mixed up display of execution of the for, with the output of the for..
I only made a one line difference between x2.bat and x3.bat (without echo tw) and the output looked a bit different 'cos cmd put the ( ) on one line for x3.bat . and I got a bit confused with the pattern.. sorry.
I only made a one line difference between x2.bat and x3.bat (without echo tw) and the output looked a bit different 'cos cmd put the ( ) on one line for x3.bat . and I got a bit confused with the pattern.. sorry.
Re: why does this FOR statement output %f and this one doesn
I still don't see the difference, apart from the obvious absence of "echo tw".
Here are the outputs side by side
Your last post came while I was editing my post
Dave Benham
Here are the outputs side by side
Code: Select all
C:\>x2 <ENTER> | C:\>x3 <ENTER>
|
C:\>for %f in (a b) do ( | C:\>for %f in (a b) do (echo %f )
echo %f |
echo tw |
) |
|
C:\>( | C:\>(echo a )
echo a | a
echo tw |
) |
a |
tw |
|
C:\>( | C:\>(echo b )
echo b | b
echo tw |
) |
b |
tw |
|
C:\> | C:\>
Your last post came while I was editing my post
Dave Benham