Multiple Cmmands on one line

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

in the do clause for a FOR statement I want to say set smurf=%i followed by
echo %i

Yes I know I could reverse the statements above but I have simplified the
example.

I would think that set smurf=%i &echo %i would be it but the & echo %i
becomes a part of the variable smurf (with a blank after the %i)

Isn't there a end to the set statement ????
 
dino said:
in the do clause for a FOR statement I want to say set smurf=%i followed by
echo %i

Yes I know I could reverse the statements above but I have simplified the
example.

I would think that set smurf=%i &echo %i would be it but the & echo %i
becomes a part of the variable smurf (with a blank after the %i)

Isn't there a end to the set statement ????

These all work OK for me:

- - - - - - - - begin screen capture WinXP MCE2005 SP2 - - - - - - - -
c:\cmd>for %i in (aaa bbb ccc) do @(set "smurf=%i" & echo %i)
aaa
bbb
ccc

c:\cmd>for %i in (aaa bbb ccc) do @set smurf=%i&echo %i
aaa
bbb
ccc

c:\cmd>for %i in (aaa bbb ccc) do set smurf=%i&echo %i

c:\cmd>set smurf=aaa & echo aaa
aaa

c:\cmd>set smurf=bbb & echo bbb
bbb

c:\cmd>set smurf=ccc & echo ccc
ccc

c:\cmd>for %i in (aaa bbb ccc) do set smurf=%i&echo %i&echo [!smurf!]

c:\cmd>set smurf=aaa & echo aaa & echo [!smurf!]
aaa
[aaa]

c:\cmd>set smurf=bbb & echo bbb & echo [!smurf!]
bbb
[bbb]

c:\cmd>set smurf=ccc & echo ccc & echo [!smurf!]
ccc
[ccc]
- - - - - - - - end screen capture WinXP MCE2005 SP2 - - - - - - - -
 
Back
Top