XOR operator (bitwise)
- Last Updated: January 18, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
Performs a bitwise exclusive OR operation on two expressions of the same flag enum type and returns a new instance of the same type.
Syntax
|
- flag-enum-expression
- An expression whose value is a flag enum instance. Both expressions must be the same
flag enum type, and neither expression can be the Unknown value
(
?).
Example
When you perform an XOR operation on two flag enum instances, the resulting instance has a flag set if the state of that flag was different for the original two expressions. For example, using this enum type:
|
The following code fragment shows examples of two different XOR operations.
|
The first XOR operation in the previous example shows how you can use bitwise XOR to
toggle a flag on and off. Performing an XOR operation on myAlignment with
an enum instance that has only one flag set will result in an instance with that flag turned
on if if it was off in myAlignment or off it was turned on in myAlignment.
The second XOR operation shows how you can use bitwise XOR to toggle the status of two
flags that you want to be mutually exclusive. When myAlignment starts with
either Top or Bottom set, but not both, using the XOR
operation with the enum instance created by the OR operation switches the status of the two
flags.
Notes
- This operator can be used with both ABL and .NET flag enums.
See also
AND operator (bitwise), ENUM statement, NOT operator (bitwise), OR operator (bitwise)