Don't take unnecessary risks! Keep your DPL Support plan current.

Find out more about DPL software's history -- one that spans over 20 years

Meet the folks behind the DPL Software

Discover opportunities at Syncopation Software

DPL 9 Help

Conditional Operator

Conditional Operator

The conditional operator (? :) takes the form:

operand1 ? operand2 : operand3

The conditional operator is the only one in DPL with three operands. It tests operand1 to see whether it is 0.
The conditional operator interprets operand1 as being true if it is not 0 and false if it is 0.
If operand1 is not 0 (true), the operator evaluates and returns operand2.
If operand1 is 0 (false), the conditional operator evaluates and returns operand3.
The conditional operator is similar to the if( ) spreadsheet function.

Examples of the conditional operator are:

x != 0 ? y/x : 0
x ? y/x : 0

The expressions are equivalent, although the first one is easier to interpret. When x does not equal 0, the expressions equal y/x.
Otherwise they equal 0.