Scripting > UNICOM Intelligence Function Library > Miscellaneous functions > BitXor
 
BitXor
Performs a bitwise XOR (exclusive OR) on two or more numeric values and returns the result.
Syntax
BitXor(Val1 [, Vals, ...])
Parameters
Val1
Type: Long
First data value.
Vals
Type: None
Variable number of other values.
(return)
Type: Long
All values exclusively OR-ed together.
Remarks
Vals is a list of variants, which are converted to Long before being used. If one or more of them cannot be converted to a long value, an error occurs.
The return value is a number with only the bits set that are set in an odd number of the input values Val1 and the other value arguments. If the current data value is NULL, Val1 is 0 and the return value is the combination of the other value arguments. If no other arguments are supplied, the return value is Val1. If only Val1 and one other value are supplied, the bits set in the return value are those bits that are set in Val1 or in the other value, but not in both.
This function is similar to using Xor as a bitwise operator in Visual Basic.
Example
BitXor can be used for reversing certain bits in a bit pattern. Like the other bit functions, BitXor, is useful when working with properties that store a numeric value in which the bits are used to record true or false values that represent whether various flags have been set. Typically a type definition is used to define the various flags. However, be aware that switching bits on and off individually is not generally recommended when using the bit field properties in the UNICOM Intelligence object models.
This mrScriptBasic example clears the bit that represents the vtFilter usage type constant if it is set and sets it if it is not set:
MyVariable.UsageType = BitXor(MyVariable.UsageType, VariableUsageConstants.vtFilter)
See also
BitAnd
Miscellaneous functions