|
  
Conditionals
Conditional expressions can be placed in definitions using the
IF primitive. IF has the format IF( cond,
x, y ) where cond is a logical
expression, x is an expression that is evaluated if the
logical expression is true, and y is an expression that is
evaluated if the logical expression is false. For example,
the following definition expands the simple definition
ROE:=Profit/Equity
to require that Profit be greater than or equal to
zero.
ROE:=IF(Profit>=0,Profit/Equity,0)
In the definition above, ROE is calculated as Profit/Equity whenever Profit is
greater than or equal to 0. Otherwise, ROE is 0.
Logical expressions used in conditionals are usually some
formula including comparison operators. Comparison operators are
primitives that compare two objects and return a logical value, true
or false, depending on the validity of an expression.
The following comparison operators are available in
DecisionPro:
Equal x==y
Not equal x!=y
Greater than x>y
Greater than or equal x>=y
Less than x<y
Less than or equal x<=y
Be careful not to confuse the comparison operator Equal (==) with the Define (:=) or Assign (=) operators.
Use the operators Logical And
(&&) Logical Or (||) to
join logical expressions as in the following example:
ROE:=IF(Profit>=0&&Equity>0,Profit/Equity,0)
This definition requires that Profit be greater than or
equal to zero AND Equity be greater than zero.
Use the Logical Not operator
(!) to invert a logical expression. That is, convert a true
result to false and a false result to true.
In other words, the expression Profit>=0
is the same as !(Profit<0).
|