Please enable JavaScript to view this site.

ESL Documentation

Convert a value to another type.

Description

ESL performs type conversions only on values in ESL statements, never inside an expression. The following table shows the conversions ESL performs:

Value

Converts to

integer

floating point

string

 

floating point

integer

string

 

string

integer

floating point

object identifier (name) with

or without

 

boolean

integer

floating point

string

 

object identifier (name) with or without ancestry

string

 

When a string contains blanks or alphabetic or special characters, ESL starts at the beginning of the string and proceeds, according to the following rules, for conversions of string values to integer or floating point values:

1. It ignores any leading blanks.

2. It examines the first non-blank character(s) in the string.

For integers, if the characters are digits (optionally preceded by a minus sign), ESL interprets the value as being an integer.

For floating point values, if the string contains a decimal point, the digits before the decimal point and after the decimal point up to the first non-digit are regarded as the floating point value.

3. It terminates at the first character that is not a digit (or decimal point, for floating point values). If it terminates before locating a number, the value is zero.

When a boolean value is used where a string value is expected, the value true will be converted to the string value "true", and the boolean value false will be converted to the string value "false".

For conversion of boolean values to integer or floating point values, the boolean value true is converted to the value 1; false is converted to the value 0.

A floating point value that is converted to an integer value is truncated at the decimal point; the value will not be rounded.

If you specify a value that cannot be converted to the required type, an error message will be generated.