WAD @EVAL

May 20, 2008
9,622
64
Syracuse, NY, USA
This is expected.
Code:
v:\> echo %@eval[(0 & 1) + 0]
0
This is not expected.
Code:
v:\> set n=0

v:\> echo %@eval[(%n & 1) + %n]
TCC: Divide by zero "(0 & 1) + %n"
 

samintz

Scott Mintz
May 20, 2008
1,346
12
Solon, OH, USA
I don't think you need the %'s inside of EVAL.
Code:
set n=0
echo %@eval[(n & 1) + n]
0
set n=1
echo %@eval[(n & 1) + n]
2
 
May 20, 2008
9,622
64
Syracuse, NY, USA
Scott is right - don't use % unless you are referencing an internal variables or function. In you example, part of the line is being expanded by the parser and part by @eval.
I have always used "%" and probably will continue. This problem is as old as the hills. The help could call some attention to it. How do you fix this one?
upload_2017-8-14_13-31-22.png
... a bunch of ways ...
upload_2017-8-14_13-32-49.png