Boolean Operators

The logical operators And, Or, and Not are used to combine Boolean expressions. The following table shows the results of combining two Boolean expressions with And and Or operators:

Expression 1 Operator Expression 2 Result

False

And

False

False

False

And

True

False

True

And

True

True

False

Or

False

False

False

Or

True

True

True

Or

True

True

In complex logical expressions using the operations And, Or, and Not, Not takes the highest precedence, And is next, and Or is lowest. Use parentheses to override precedence. (Generally, it is a good idea to use parentheses in logical expressions anyway, because it makes them easier to decipher.) If used on the right side of an assignment statement, Boolean expressions must be enclosed in parentheses.

The following are examples of statements containing Boolean expressions:

If ((&HAS_FLEAS Or 
      &HAS_TICKS) And 
      SOAP_QTY <= MIN_SOAP_QTY) Then
   SOAP_QTY = SOAP_QTY + OrderFleaSoap(SOAP_ORDER_QTY);
End-If;

The Not operator negates Boolean expressions, changing a True value to False and a False value to True. The Not operator can also negate comparison operators.

There are several methodologies for negating a Boolean value. You can use the Not operator:

Local boolean &Flag;

&Flag = True;
&Flag = ( Not &Flag);
If Not &Flag Then
   WinMessage("Flag = False");
End-If;

Alternatively, you can compare the Boolean value to False:

Local boolean &Flag;

&Flag = True;
&Flag = (&Flag = False);
If Not &Flag Then
   WinMessage("Flag = False");
End-If;