logo-header

 
 

syntax

  • iif(condition, then, else)
  • conditionthenelse

definition

iif(condition, then, else) or condition ? then : else results in a data item with as expression the subexpression then if the condition is true and else if the condition is false.

description

The iif function results in a data item with the same domain and values unit as the subexpressions then and else.

iif statements can be nested, but it is advised to use the switchcase function for nested statements.

In the evaluation of an iif function, both then and else subexpressions are calculated. If an indirect expression is used, the resulting expression will only contain the then or else subexpression, the other statement does not have to be calculated. This can be usefull if the calculation of one of both subexpressions is time consuming or illogical. See for instance example 3 of RelateToGrid.

applies to

Condition with bool value type

Subexpressions then and else

conditions

1. The domain of condition, subexpressions then and else and the resulting data item must match or be void (literals or parameters can be combined with data items of any domain).
2. The values unit of subexpression then and else and the resulting data item must match.

since version

5.15

example

attribute<float32> iifAgteB (ADomain) := iif(A >= B, 1f, 0f);
attribute<float32> iifAgteB (ADomain) := A >= B ? 1f : 0f;
A(float32) B(float32) iifAgteB
0 2 0
1 2 0
2 2 1
3 2 1
null 2 0
ADomain, nr of rows = 5

see also


OBJECT VISION BV
Vrije Universiteit
De Boelelaan 1085
1081 HV Amsterdam
The Netherlands

tel: +31 (0)20 598 9083
fax:+31 (0)20 598 9904