Skip to main content

# Or (! or ||)

Tests if either or both operands have a value of TRUE.

## Details

The Or operator produces a result of TRUE (1) if either operand has a value of TRUE or if both operands have a value of TRUE (1). Or produces a result of FALSE (0) only if both operands are FALSE (0).

There are two forms to Or:

• The ! operator evaluates both operands and returns a value of FALSE (0) if both operand evaluates to a value of zero. Otherwise it returns a value of TRUE (1).

• The || operator evaluates the left operand. If the left operand evaluates to a nonzero value, the || operator returns a value of TRUE (1) without evaluating the right operand. Only if the left operand evaluates to zero does the || operator then evaluate the right operand. It returns a value of FALSE (0) if the right operand also evaluates to a value of zero. Otherwise it returns a value of TRUE (1).

## Examples

The following examples evaluate two TRUE (nonzero) operands, apply the Or to them, and produces a TRUE result:

`````` SET A=5,B=7
WRITE "A!B = ",A!B,!
SET A=5,B=7
WRITE "A||B = ",A||B,!``````

both return TRUE (1).

The following examples evaluate one false and one true operand, apply the Or to them, and produces a TRUE result:

`````` SET A=0,B=7
WRITE "A!B = ",A!B,!
SET A=0,B=7
WRITE "A||B = ",A||B,!``````

both return TRUE (1).

The following examples evaluate two false operands and produces a result with a value of FALSE.

`````` SET A=0,B=0
WRITE "A!B = ",A!B,!
SET A=0,B=0
WRITE "A||B = ",A||B,!``````

both return FALSE (0).

FeedbackOpens in a new tab