Back Forward Expressions — Advanced topics

  Show all 

C-471 Advanced featureThis topic describes details of expression evaluation. If you're experienced in Java, note that most behavior of Process Commander expressions correspond to the Java Language Specification, Chapter 15.

 Up Order of evaluation

Expressions are evaluated as follows:

  1. Process Commander evaluates expressions from left to right.
  2. The target property reference (the destination for a value) is evaluated completely before the expression (the source of the value) is evaluated.
  3. Evaluation reflects nesting within parentheses, and operator precedence.
  4. Partial expressions combined by an operator are evaluated before the operation, with a few exceptions: For the logical functions @if(), @and(), and @or(), and the conditional operators (&&, || and ?:) only those operands needed to determine the true or false result are evaluated.
  5. Argument lists for functions are evaluated left to right.

  Add (+) and subtract (-) operations

This table shows the valid combinations of types when the operator is + or -. To understand the calculation of the expression A + B, find the type of A in the Left Hand Side (rows) of each table. Find the type of B in the Right Hand Side (columns) if the table. Consult the numbered notes for the details of casting or conversion.

Right Hand Side

DateTime

Date

Time of Day

Integer

Decimal

Double

True or False

Other (text)

Left Hand Side

DateTime

3

3

3

5

5

5

X

1

Date

X

3

4

5

5

5

X

1

Time of Day

X

4

3

X

5

5

X

1

Integer

5

5

X

2

2

2

X

1

Decimal

5

5

5

2

2

2

X

1

Double

5

5

5

2

2

2

X

1

True or False

X

X

X

X

X

X

X

1

Other (text)

1

1

1

1

1

1

1

1

X indicates that a casting, promotion or conversion is not supported. Process Commander reports an error.

  1. For +, performs Java String concatenation (result is of mode Single Value). The minus operator (-) is not permitted.
  2. Converts Integer > Double > Decimal until both operands have same type, then perform operation. Result is of the promoted type. (Converts directly to the target type without performing intermediate conversions.)
  3. The + operator is not permitted. The - operator converts operands to Decimal and performs the operation, yielding Decimal number of days and fraction of day.
  4. The + operator converts operands to Decimal and performs the operation, yielding a DateTime with GMT assumed. The - operator is not permitted.
  5. Converts operands to Decimal and performs the operation, yielding a Date (rounded), Time of Day or DateTime (depending upon type of original non-numeric operand)

  Multiply, divide, and remainder operations (*, /, %)

This table shows the valid combinations of types when the operator is *, / or %. To understand the calculation of the expression A * B, find the type of A in the Left Hand Side (rows) of each table. Find the type of B in the Right Hand Side (columns) if the table. Consult the numbered notes for the details of casting or conversion.

Right Hand Side

DateTime

Date

Time of Day

Integer

Decimal

Double

True or False

Other (text)

Left Hand Side

DateTime

X

X

X

X

X

X

X

X

Date

X

X

X

X

X

X

X

X

Time of Day

X

X

X

X

X

X

X

X

Integer

X

X

X

1

1

1

X

X

Decimal

X

X

X

1

1

1

X

X

Double

X

X

X

1

1

1

X

X

TrueFalse

X

X

X

X

X

X

X

X

Other (text)

X

X

X

X

X

X

X

X

Notes for multiplication, division, and remainder operations:

  1. Convert Integer > Double > BigDecimal until both operands have same type, then perform operation. B-11395 The result is of the promoted type. (Conversion is directly to target type without performing additional intermediate conversions.)
  2. Integer divide operations with the / operator provide no rounding. For example, 10/6 = 1. You can use the built-in function @divide(dividend, divisor, mode) with Integer or Decimal operations to compute a result that contains at least two decimal places and rounds half values up: @divide(10, 6) = 1.67. C-1821 B-11393 B-11395 Rounding modes are the same as for the BigDecimal class:
    • ceiling — round to a more positive integer
    • down — round towards zero
    • floor — round to a more negative number
    • half_down — round to the nearest neighbor, where an equidistant value is rounded down
    • half_even — round to the nearest neighbor, where an equidistant value is rounded to an even value
    • half_up — round to the nearest neighbor, where an equidistant value is rounded up
    • unnecessary — assert that no rounding is necessary
    • up — round away from zero

  Comparison operators (<, <=, >=, ==, !=, ...)

This table shows the valid combinations of types for comparison operators. To understand the calculation of the expression A > B, find the type of A in the Left Hand Side (rows) of each table. Find the type of B in the Right Hand Side (columns) if the table. Consult the numbered notes for the details of casting or conversion.

NoteThe operator ~= evaluates using equalsIgnoreCase().

Right Hand Side

DateTime

Date

Time of Day

Integer

Decimal

Double

True or False

Other (text)

Left Hand Side

DateTime

1

3

X

3

3

3

X

X

Date

3

1

X

3

3

3

X

X

Time of Day

X

X

1

X

3

3

X

X

Integer

3

3

X

2

2

2

X

X

Decimal

3

3

3

2

2

2

X

X

Double

3

3

3

2

2

2

X

X

True or False

X

X

X

X

X

X

4

X

Other (text)

X

X

X

X

X

X

X

5

Legend:

X

A casting, promotion, or conversion is not supported. Process Commander reports an error.

1

Permitted. Depending upon complexity of expression and intermediate conversions that may have occurred, use either the original ClipboardProperty String form or Java BigDecimal.

2

Permitted. Converts Integer > Double > Decimal until both operands have same type, then performs operation. (Convert directly to target type without performing additional intermediate conversions.)

3

Permitted. Converts to the preferred Java type (and if necessary, promote as described in note 2) and performs the operation.

4

Permitted. Converts to Java boolean and performs the operation.

5

Permitted. Evaluate using String.compareTo(). NoteThis is not locale-sensitive.

UpAbout Expressions