ph_or PowerHome formula function
Description
Bitwise OR’s two numbers.
Syntax
ph_or ( val1, val2 )
Argument | Description |
val1 |
Long. Unsigned long value of the first operand. |
val2 |
Long. Unsigned long value of the second operand. |
Return value
Unsigned long. Returns the value of the two operands OR’ed together.
Usage
Used to compare boolean values to determine if either is true, or not. Can also be used to combine bits from a binary value. See examples below.
In addition to the ph_or() function, the stand-alone OR operator is also available for use in boolean testing, typically in IF functions. Using the OR operator this way often makes code more 'readable' and has the added advantage that more than two variables can be compared.
A typical use of the OR operator in an IF function is...
• if(now() > 09:00:00 or {DARK} =
0 or {ON}= 1,1,0)
Examples
The following examples demonstrate typical syntax/usage for this function.
ph_or({DARK},{HOME}) |
Yields a "1" if either the DARK or HOME Globals are true (ie, equal to 1) |
ph_or(8,2) |
Yields "10" {0b1000 AND 0b0010 >> 0b1010} |
ph_or(10,2) |
Yields "10" {0b1010 AND 0b0010 >> 0b1010} |
ph_or(21,[LOCAL1]) |
Yields "23" if LOCAL1=3 {0b10101 AND 0b00011 >> 1} |