Function BOr() Foundation
Calculates the result of a bitwise OR operation.
BOr( <nVa1>, <nVal2>, [<nVal3>,...] ) -> nBitwiseOr
BOr() returns the result of a bitwise OR operation between operands <nVal1> and <nVal2>. If additional parameters are passed, another bitwise OR operation is performed for each parameter. Once all parameters are processed, BOr() returns the combined result of the OR operation.
BOr() is a numeric function that performs a bitwise OR operation between two or more operands. A bitwise OR turns on all bits in the result that a corresponding bit set in one or more operand(s). The following table illustrates this correlation.
Operand 1 | Operand 2 | Result |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 1 |
Bitwise operations are usually used with flag values, where a certain bit pattern represents a certain option being enabled or disabled. Using the function BOr(), an individual option can easily be included (enabled) in the flag value.
// The example illustrates an exemplary usage of function BOr()
#define OPTION_1 1
#define OPTION_2 2
#define OPTION_3 4
#define DEFAULTS OPTION_1
PROCEDURE Main()
LOCAL nSetting := DEFAULTS
nSetting := InclOption( nSetting, OPTION_2 )
? nSetting // Result: 3 (OPTION_1 + OPTION_2)
nSetting := InclOption( nSetting, OPTION_3 )
? nSetting // Result: 7 (OPTION_1 + OPTION_2 +
// OPTION_3)
WAIT "Done."
RETURN
// Include option 'nOption' in the
// value passed
FUNCTION InclOption( nValue, nOption )
RETURN BOr(nValue, nOption)
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.