Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@EVAL, "AND" vs. "&"

May
12,845
164
They don't seem to work the same:.

Code:
v:\> echo %@eval[( %_minute AND %_minute ) / %_minute]
1

v:\> echo %@eval[( %_minute & %_minute ) / %_minute]
Eval warning: 'sdivide', Divide by 0
TCC: Divide by zero "( 20 & %_minute ) / %_minute"
It would seem that the parsing stopped early.

And what's with the "Eval warning"? It doesn't appear in other similar circumstances.

Code:
v:\> set x=2 & set y=2 & set z=2 & set a=2

v:\> echo %@eval[(%x AND %y) / %z]
1

v:\> echo %@eval[(%x & %y) / %z]
TCC: Divide by zero "(2 & %y) / %z"
 
They don't seem to work the same:.

Code:
v:\> echo %@eval[( %_minute AND %_minute ) / %_minute]
1

v:\> echo %@eval[( %_minute & %_minute ) / %_minute]
Eval warning: 'sdivide', Divide by 0
TCC: Divide by zero "( 20 & %_minute ) / %_minute"

It would seem that the parsing stopped early.

Well, the ampersand is the command separator. What happens if you escape it? Or do e.g. SETDOS /C0x13FF first?
 
On Fri, 04 Mar 2011 21:48:37 -0500, Charles Dye <> wrote:

|Well, the ampersand is the command separator. What happens if you escape it? Or do e.g. SETDOS /C0x13FF first?

Command separators are generally OK inside variable functions. Escaping it
works but that shouldn't be necessary. It is certainly not neseccary if there's
no variable substitution needed at all, or if variables (env only) are mentioned
without the '%'.

Code:
v:\> echo %@eval[(2 & 2) / 2]
1

v:\> set x=4 & set y=7 & set z=2

v:\> echo %@eval[(x & y) / z]
2
 
On Fri, 04 Mar 2011 22:46:13 -0500, rconn <> wrote:

|If you have variables, the line has to be passed back to the variable
|expansion, and if you haven't quoted or escaped the & it will be treated as
|a command separator.
|
|It's worked that way forever.

I thought exactly that and that it was a bug. Most users (including myself)
aren't very savvy when it comes to the working of the parser. The help merely
says "& same as AND".
 
---- Original Message ----
From: rconn
| Quote:
|| Command separators are generally OK inside variable functions.
|
| If you have variables, the line has to be passed back to the variable
| expansion, and if you haven't quoted or escaped the & it will be
| treated as
| a command separator.
|
| It's worked that way forever.

This is one of the reasons I do not use the ampersand character & as the command separator. As Charles suggested, when literal & is needed, make sure it is not your command separator.
--
Steve
 
I thought exactly that and that it was a bug. Most users (including myself) aren't very savvy when it comes to the working of the parser. The help merely says "& same as AND".

I see different-but-related issues when using | for logical OR in an expression containing expandables. It's probably safest to always use words instead of symbols wherever there's an overlap. (And perhaps the latter should be de-documented or deprecated?)
 
Back
Top