# Converting Values with Converters

The Converter is a function that converts the values of source properties as defined in the settings.

Create a converter in the Converter Editor. Select the converter when associating an object property with a source property to reflect the converted value to the property.

Note: For information on associating source properties, refer to the following.
Data Binding

Creating Converters

Using Converters

Expression Editor

## Creating Converters

1. From the [Project Explorer] go to [Converters] → [User-Defined Converters].
2. From the toolbar in the converter editor, select the type of converter.
   Types of Converters
3. Configure the converter settings in the Properties window. For more information, refer to the Converter’s properties.
   Properties (Unit Converter)
   Properties (Range Converter)
   Properties (Scale Converter)
   Properties (Expression Converter)

Note: Use the Expression Editor to create expressions for the Expression Converter.
Expression Editor

## Using Converters

When associating an object property with a source property, select a converter in the property selector window.

1. In the object properties that you want to use with a converter, click the square icon (property marker) next to the property to select the source property type.
2. In the Property Selector window, select a source property.
3. Click [Converter] to display the settings.
4. Select the [Converter] checkbox and select a converter from the converters that were created beforehand.
5. Select [Direction].

   Note:

   For information on [Direction], refer to the following.
   Data Binding [Direction]

   The Range Converter and Expression Converter support [One Way] only. When using those converters, [Direction] is set to [One Way] automatically.

6. Click [OK]

   Note: If the [Direction] is [One Way], no input is possible from an object, such as a Numeric Display. Clear the checkbox if the object has the [Enable Input Mode] property.

## Expression Editor

In the Expression Editor, create expressions to use in the Converter. From the Expression Converter Properties window, click the ellipsis [...] of the [Expression] field to display the Expression Editor.

### Expression Editor

1: Type the expression and operator. You can also insert an operator from the shortcut menu that appears when right-clicking an expression (Example: To insert *, right-click and select [Operators]).

Note: For information about the rules for expressions, refer to the following.
Rules for Expressions

2: Select the object type to insert in the expression. The object list will change.

3: Select the object to insert in the expression. When you click the object, the object is inserted at the expression cursor position.

### Rules for Expressions

#### Operators

For more information about supported operators and how it works, see Available Operators and Functions.

#### Data Type

If the data types are identical, you can use multiple variables in one expression. The following is an example of a valid expression, where the two variables are of the same DINT data type:

MyDINT01 + MyDINT02

The following is an example of an invalid expression, where the two variables are of data types DINT and STRING respectively:

MyDINT01 + MyString01

When expressions are displayed in red, it means that there is an error in the expression. Variables with different data types will not work in an expression.

#### Calculation

When the data of expression is changed, the calculation will be performed immediately.

#### Decimal digits

- The precision of value used in expression is limited to 15 digits.
- When you use 16 or more decimal digits in a mathematical expression, then use LINT or ULINT as the destination variable.

#### Decimal Points

The mathematical expression result contains decimal points.
(Example 1)
In the following case, if the value of INT1 is 101, then the result is 10.1 (.1 is not truncated).

To truncate the decimal points, use the floor block.
(Example 2)
In the following case, if the value of INT1 is 101, then the result is 10.

#### Strings

- Enclose strings in single or double quotation marks. (Example: 'ABC' or "ABC")
  You cannot use single quotation marks like a normal character.
  However, you can use double-quotation marks like a normal character by enclosing them inside single quotation marks. (Example: '"ABC"')
- The backslash character is used for escape characters. To use a backslash like a normal character, type the backslash twice. (Example: \\)