First, batch file 1:
and the results of running batch file 1:
Now batch file 2:
and the results of running it:
The question is actually pretty simple: why doesn't batch file 2 run the same as batch file 1, which is what I would expect? After all, the only difference between the two batch files is that one tests a variable in the Do While whereas the other tests the @Field expression directly in The Do While. Why is that not allowed?
Oh, just as another question, why does %_CMDLine only contain the first argument?
Code:
@Echo Off
SetLocal
@Echo %%*: %*
@Echo %%#: %#
@Echo _CMDLine: %_CMDLine
Set Value="%@Field[1," ",%*]"
Set I=1
Do While %Value != ""
@Echo "%%@Field[%I," ",*]: %Value
Set /A I+=1
Set Value="%@Field[%I," ",%*]"
EndDo
EndLocal
Code:
[Z:\TCC Histories]VarRef1 a=b c=d e=f
%*: a=b c=d e=f
%#: 6
_CMDLine: VarRef a
"%@Field[1," ",*]: "a=b"
"%@Field[2," ",*]: "c=d"
"%@Field[3," ",*]: "e=f"
Now batch file 2:
Code:
@Echo Off
SetLocal
@Echo %%*: %*
@Echo %%#: %#
@Echo _CMDLine: %_CMDLine
Set Value=
Set I=1
Do While "%@Field[%I," ",%*]" != ""
@Echo "%%@Field[%I," ",*]: "%@Field[1," ",%*]"
Set /A I+=1
EndDo
EndLocal
Code:
[Z:\TCC Histories]VarRef2 a=b c=d e=f
%*: a=b c=d e=f
%#: 6
_CMDLine: VarRef2 a
TCC: Z:\TCC Histories\VarRef2.btm [8] Syntax error "@Field[%I,""
Z:\TCC Histories\VarRef2.btm [8] Usage : DO [n | FOREVER]
TCC: Z:\TCC Histories\VarRef2.btm [13] Unknown command "EndDo"
The question is actually pretty simple: why doesn't batch file 2 run the same as batch file 1, which is what I would expect? After all, the only difference between the two batch files is that one tests a variable in the Do While whereas the other tests the @Field expression directly in The Do While. Why is that not allowed?
Oh, just as another question, why does %_CMDLine only contain the first argument?