CDL Iterator Statements and the FOR ALL...IN and WHERE Keywords
The FOR ALL, IN, and WHERE keywords support iterator statements.
FOR ALL and IN Keywords
The FOR ALL and IN keywords begin the two clauses of an iterator statement. The IN keyword specifies the source of iteration.
Note: The IN clause can contain only literal collections or collections of model nodes, such as OptionsOf. There's no specification of instances, so all instances of a given Model use the same iteration.
WHERE Keyword
The WHERE keyword begins a clause of an iterator statement that acts as a filter to eliminate iterations that don't match with the WHERE criteria
In the example FOR ALL IN and
WHERE Clause using Node Attributes
, the result is only as
many contributions to option d
as there
are children in the criteria specified in the WHERE clause.
Note: The conditional expression in the WHERE clause must be static. When using the COLLECT operation in a WHERE and an IN clause, the operands must be static.
Note: Configurator evaluates compatibility rules from the top down, and gives no priority or precedence to an expression based on its use of the AND or OR operator. In other words, the first relation you enter is evaluated, followed by the second, and so on.
Examples
In the following example,
the result is 3 contributions to option d
.
ADD &var TO d
FOR ALL &var IN {a, b, c};
In the following example, the
result is as many contributions to numeric feature d
as there are children in option class a
, whose user-defined attribute UDA3
is less than 5. This example also shows a collection enclosed in
braces (see Collection Literals).
Example: FOR ALL IN and WHERE Clause using Node Attributes
ADD &var.userAttrs["AG_name.NumAttr"]+ 10 TO d
FOR ALL &var IN {OptionsOf(a)}
WHERE &var.userAttrs["AG_name.UDA3"] < 5;
In both examples, a single statement explodes into one or more constraints or contributions without explicitly repeating each one. In both examples, the iterator variable can also participate in the left hand side of the accumulator statement.