Nice to see the input.
First, the observations of dbenham.
The **call** behaviour is "normal", as call fails complete if there is a block, & or | in the second run of parsing.
Code: Select all
call echo 1: Hello & echo 1: you
call echo 2: Hello ^& echo 2: you
call ( echo 3: Hello ) & echo 3: you
Output:
As the & simply splits the line in the examples 1 and 3 into two seperate commands.
dbenham wrote:echo ---- Test4 ----
echo But ignored call breaks direct myBatch.
call (but direct now fails)&myBatch !var1!
That is the normal behaviour for batch files, batch files have to be called (to return), else it works like a "goto"
@aGerman:
aGerman wrote:seems that !var2! does not expand in Caller.bat.
Yes, that's the simple cause, why it works.
This behaviour is new for me, but not so sensational as I first think.
But I found another curious behaviour at ths point.
Caller.bat
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set lf=^
set var2=hello^
echo you
echo ---- direct Test2 ----
echo on
for %%A in (111 222 333) do (
myBatch !var2!%%A
)
I modified the myBatch.bat a bit, at the **REM**, I surround it with parenthesis, so I can see the complete multiline output of %*
**Output**
Code: Select all
---- direct Test2 ----
C:\temp>for %A in (111 222 333) do (myBatch !var2!%A )
C:\temp>(myBatch !var2!111 )
NOT OK
C:\temp>(
rem hello
echo you111 #
)
you111 #
1:hello
2:hello
you111
C:\temp>(myBatch !var2!222 )
NOT OK
C:\temp>(rem !var2!222 # )
1:!var2!222
2:!var2!222
C:\temp>(myBatch !var2!333 )
NOT OK
C:\temp>(rem !var2!333 # )
1:!var2!333
2:!var2!333
As you can see, in the first call of myBatch.bat the parameters are 'hello<LF>you111',
but for the second and third loop they are '!var2!222' and '!var2!333'.
There are always new things to explain.
jeb