Operator ORELSE (Short Circuit Inclusive Disjunction)

Returns the short circuit-or (Inclusive Disjunction) of two numeric values

declare operator OrElse ( byref lhs as T1, byref rhs as T2 ) as Ret

result = lhs OrElse rhs

The left-hand side expression.
Any numeric or boolean type.
The right-hand side expression.
Any numeric or boolean type.
A numeric or boolean type (varies with T1 and T2).

Return Value:
Returns the short circuit-or (inclusive disjunction) of the two operands.

This operator evaluates the left hand side expression. If the result is nonzero, then -1 (true) is immediately returned. If the result is zero then the right hand side is evaluated, and the logical result from that is returned, returning -1 (true) for a nonzero value or 0 (false) for zero.
(for conversion of a boolean to an integer, false or true boolean value becomes 0 or -1 integer value)

The truth table below demonstrates all combinations of a short circuit-or operation, the '-' denotes that the operand is not evaluated.

Lhs Value Rhs Value Result
0 0 0
0 nonzero -1
nonzero - -1

Short-circuiting is performed - only expressions needed to calculate the result are evaluated.

The return type is almost always an Integer, of the value 0 or -1, denoting false and true respectively. Except if the left and right-hand side types are both Boolean, then the return type is also Boolean.

This operator cannot be overloaded for user-defined types.

' Using the ORELSE operator on two numeric values
Dim As Integer numeric_value1, numeric_value2
numeric_value1 = 15
numeric_value2 = 30

'Result = -1
Print numeric_value1 ORELSE numeric_value2

Differences from QB:
See also:
Back to Short Circuit Operators
Back to Operators
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki

sf.net phatcode