Back Forward Data type conversions (casting) in expressions and property assignments

Every expression has a Type, which Process Commander deduces from the structure of the expression and the data types of the constants, functions, and clipboard properties mentioned in the expression.

You can enter a valid expression in a context for which the Type is not appropriate. For example, if you enter an expression in a when condition rule that is not of type True or False, then Process Commander reports an error when you try to save the rule.

In many situations, Process Commander automatically converts the type of the expression to a type acceptable for the context. (In many programming languages such conversions are known as casting or typecasting.)

Process Commander automatically perform the conversions when evaluating expressions and making assignments (such as to a target property in the Property-Set method):

To type

DateTime

Date

Time of Day

Integer

Decimal

Double

True or
False

Other (Text, Identifier)

From type

DateTime

zzz

D

D

V

V

V

zzz

  C

Date

V, 2

zzz zzz

V, 5

V, 5

V, 5

zzz

  C

Time of Day

zzz zzz zzz

VN 3

V, 4

V, 4

zzz

  C

Integer

V, 1

V, 5

V, 3

zzz

V

V

zzz 6

  C

Decimal

V, 1

V, 5

V, 4

N

zzz

V

zzz 6

  C

Double

V, 1

V, 5

V, 4

N

V

zzz zzz 6

  C

True or False

zzz zzz zzz zzz zzz zzz zzz

  C

Other

S

S

S

S

S

S

S

  zzz

Entries in this table indicate whether and how automatic conversion occurs:

Entry

Description

 Yes

No conversion necessary

 No

Conversion is not permitted.

C

Copies the value without examining whether it is valid.

S

Copies the value with no changes, then tests the result. If the value is not suitable for the target type, marks the property with the External attribute. The External attribute indicates that the value is in the form entered by the user and is not suitable for the type of the property; its use is likely to result in an error.

AdvancedYou can test this attribute through these three Public API methods in the ClipboardProperty interface:

  • hasGoodValue() — Returns true if the property is not empty and does not have the Error attribute or External attribute set, false otherwise.
  • hasInvalidValue() — Returns true if the property is not empty and has the External attribute set, or false otherwise.
  • hasValidValue() — Returns true if the property is not empty and does not have the External attribute set, false otherwise.

D

Date narrowing conversion, the appropriate subfield is selected and used

CautionResults of this conversion are correct only for the London time zone. See Understanding the Date, Time, and DateTime property types for an alternative approach that is often preferable.

N

Numeric narrowing conversion, the fractional portion is rounded.

V

Uses a preferred numeric conversion (double, BigDecimal) as defined for the respective data types above

1

Conversion of a numeric type to DateTime treats the value as a DateTime in the GMT time zone and appends GMT.

2

Conversion of Date to DateTime appends a time of 00:00:00.000 and a time zone of GMT.

3

Integer to Time of Day considers the Integer value to be a number of seconds since midnight. Time of Day to Integer sets the integer value to the number of seconds since midnight.

4

Decimal and Double to Time of Day considers the fractional component to be a fraction of a day and ignores the integer component (to the left of the decimal point). Time of Day to Decimal and Double set the fractional component of a day.

5

Numeric types converted to Date treat the (rounded) value as the number of days from the Java epoch (January 1, 1970). Date types converted to numeric types supplies the number of days (plus or minus) from the Java epoch.

For example, the integer value 0 is converted into the Date value 19700101.

 6

When converting a number to True or False, zero is converted to false, and any value other than zero is true.

The TextEncrypted type, not shown in the table above, usually holds an encrypted text value. No automatic conversions occur for assignments to or from TextEncrypted type. See Property form — Implementing and using the TextEncrypted Type.

Definitionsexpression, type

Related topicsAbout expressions