Welcome!

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

SignUp Now!

IF and !

May
12,846
164
I'm just curious about the peculiar behavior of the exclamation point.

Code:
v:\> if ! == 1 (echo yes) else (echo no)
yes

v:\> if ! EQ 1 (echo yes) else (echo no)
Usage : IF [/I] [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition ...] command

v:\> if 1 == ! (echo yes) else (echo no)
no

v:\> if 1 EQ ! (echo yes) else (echo no)
no
 
I'm just curious about the peculiar behavior of the exclamation point.

Code:
v:\> if ! == 1 (echo yes) else (echo no)
yes

v:\> if ! EQ 1 (echo yes) else (echo no)
Usage : IF [/I] [NOT] condition [.AND. | .OR. | .XOR. [NOT] condition ...] command

v:\> if 1 == ! (echo yes) else (echo no)
no

v:\> if 1 EQ ! (echo yes) else (echo no)
no

I'm a bit baffled as to your intentions, but the result is WAD.

The syntax:

if ! == 1 (echo yes) else (echo no)

equates to "compare an empty string to the string "1", and then invert the result". Putting the NOT test ("!") on the (wrong) side of the comparison results in a string test comparing "1" to "!".
 
Back
Top