CDL Operators
An operator is a predefined token that consists of Unicode characters. You use it to specify the operation to perform at run time between operands.
Operators That You Can Use
Operator Type | Operator | Description |
---|---|---|
Logical | AND |
|
Logical | OR |
|
Logical | NOT |
|
Logical | REQUIRES |
|
Logical | IMPLIES |
|
Logical | EXCLUDES |
|
Logical | NEGATES |
|
Logical and Comparison | LIKE |
|
Logical and Comparison | NOT LIKE |
|
Logical, Arithmetic, and Comparison | = |
|
Logical, Arithmetic, and Comparison | > |
|
Logical, Arithmetic, and Comparison | < |
|
Logical, Arithmetic, and Comparison | <> |
|
Logical, Arithmetic, and Comparison | <= |
|
Logical, Arithmetic, and Comparison | >= |
|
Arithmetic | * |
|
Arithmetic | / |
|
Arithmetic | - |
|
Arithmetic | + |
|
Arithmetic | ^ |
|
Arithmetic | % |
|
Text | + |
|
Other | Assign(node) |
|
Other | IncMin() |
|
Other | ( ) |
|
Other | , |
|
Other | . |
|
Other | - |
|
Operator Data Types
Operator | Data Type |
---|---|
Arithmetic |
Integer Decimal |
Logical | Boolean |
Comparison | Boolean |
You can use the result of each operator as an operand of another operator. Each of these operators must use the same data type. For example:
- If operator x is a decimal, and if operator y is a decimal, then you can use the results of x as an operand of y.
- If operator x is a decimal, and if operator y isn't a decimal, then you can't use the results of x as an operand of y.
Operator Precedence
Configurator uses this precedence when it processes operators:
Precedence | Operator | Description |
---|---|---|
1 (right) | () |
Parenthesis |
2 (right) | . |
Navigation |
3 (right) | ^ |
Arithmetic power |
4 | Unary + , - NOT |
Unary plus and minus, Not |
5 (left) | *, /, % |
Arithmetic multiplication and division |
6 (left) | Binary + , - |
Arithmetic plus and minus, text concatenation |
7 (left) | <, >, =, <=, >=, <> LIKE, NOT LIKE |
Comparison operators |
8 (left) | AND |
Logical AND |
9 (left) | OR |
Logical OR |
10 (left) | DEFAULTS, EXCLUDES, NEGATES, IMPLIES, REQUIRES |
Logic operators |
If two or more operators have the same precedence, then Configurator processes them from left to right as they appear in the rule.
LIKE and NOT LIKE Operators
You can include the LIKE operator and the NOT LIKE operator to compare text.
- You can use them only on static context. For example, you can use the WHERE clause of an iterator.
- You can use LIKE or NOT LIKE with a run time participant only if the operator evaluates to a constant string. Configurator validates this condition when you save the model.
Use LIKE to Get a Boolean Value
Consider this example:
a.attr.Value() LIKE "%eig%"
Here’s how that works:
If the Text of a.attr Contains | Then Configurator Returns |
---|---|
eig , such as a.attr =weight or
eight |
true |
Rein |
false |
In this example, if the user selects option A and option B, and if the value of their attributes is A1B1, then the rule selects all options in C:
Constrain Alltrue('A','B') implies &C
for all &C in {optionsof('C')}
where &C.userAttrs["Selections.AB Compatibility"] like "A1B1"
If the user selects option A and option B, and if the value of their attributes isn't A1B1, then the rule selects all options in C:
Constrain Alltrue('A','B') implies &C
for all &C in {optionsof('C')}
where not (&C.userAttrs["Selections.AB Compatibility"] like "A1B1" )
Concatenate Text Operator
You can use the +
(plus sign) to concatenate text.
- You can use it only with static text. For example, you can use it in an iterator's WHERE clause.
- You use it in the body of a constraint or contributor statement only if it evaluates to a constant string. Configurator validates this requirement when you save the model.
Collect Operator
You can use the Collect keyword to create a collection and then provide the collection
to an operator that can use a collection as an argument. For example, instead of
AnyTrue(x, y, z)
, you can write AnyTrue(COLLECT &c FOR
ALL &c IN {x,y,z})
.