Difference between revisions of "Or"
From Xojo Documentation
m (1 revision) 
m (1 revision) 
(No difference)

Revision as of 18:53, 19 November 2009
Contents
Description
Used to perform a logical Or comparison between two Boolean expressions or a bitwise Or comparison between two integers.
Syntax
result=expression1 Or expression2
Part  Type  Description 

result  Boolean or Integer  A Boolean value if expression1 and expression2 are boolean and an integer if expression1 and expression2 are integers. 
expression1  Boolean or Integer  Any valid Boolean or integer expression. Expression1 and expression2 must be of the same data type. 
expression2  Boolean or Integer  Any valid Boolean or integer expression. Expression1 and expression2 must be of the same data type. 
Notes
The Or operator is overloaded. If it is passed two booleans, it performs a logical Or and returns a boolean. If it is passed two integers, it performs a bitwise Or operation on the integers and returns an integer. In this case, it is equivalent to calling the BitOr method of the Bitwise class.
In the first instance, if either boolean expression evaluates to True, then result is True. If both expressions evaluate to False then result is False. The truth table for REALbasic's logical operators is shown below.
Expression1  Expression2  Or  And  Xor 

True  True  True  True  False 
True  False  True  False  True 
False  True  True  False  True 
False  False  False  False  False 
If you pass two integers, Or returns an integer that is the result of comparing each bit of the two integers passed and assigning 1 to the bit position in the integer returned if either of the bits in the same position in the integers passed are 1. Otherwise, 0 is assigned to the bit position.
The following table shows the results for REALbasic's bitwise operators:
Integer1  Integer2  Or  And  Xor 

0  0  0  0  0 
0  1  1  0  1 
1  0  1  0  1 
1  1  1  1  0 
Examples
This example uses the Or operator to perform logical comparisons
a=True
b=False
d=a Or b //Returns True
d=b Or c //Returns False

.
See Also
And, Not, Xor operators; Bitwise class; Operator_Or function; Operator precedence.