Using Expression Designer Functions

The Expression Designer supports the following functions:

Mathematical Functions

Function/Description Syntax Example
Abs: Returns the absolute value of a number. Abs(expression) Abs(-2) and Abs (2) both return 2.
Round: Returns a number rounded to the nearest integer. Round(expression) Round(1.3333) returns 1
Max: Compares two numbers and returns the largest number. Max(number1,number2) Max(-123,12) returns 12
Min: Compares two numbers and returns the smallest number. Min(number1,number2) Min(-123,12) returns -123

String Functions

Function/Description Syntax Example
Contains: Returns whether a string is contained within another or not. Contains( string1,string2)

Contains("Hello World", "Hello") returns true.

Contains("Hello World", "Goodbye") returns false

Find: Returns the position of the first occurrence of one string within another. Find( string1,string2) Find("abcd","c") returns 3
FormatDate: Returns a date string based on the date, date format, and locale. FormatDate( date, format, locale) FormatDate("May 13, 2009", "MM/dd/yy", "en-US") returns "05/13/09"
FormatTime: Returns a time string based on the time, time format, and locale. FormatTime( time, format, locale) FormatTime("23:02:33", "hh:mm tt", "en-US") returns "11:02 PM "
Left: Returns a specified number of characters from the left side of a string. Left( string,length) Left("abcd",2) returns "ab"
Length: Returns the number of characters in a string. Length( string ) Length("abcd") returns 4
MakeLower: Converts a text string to lowercase characters. Makelower(string) Makelower("ABCD") returns "abcd"
MakeUpper: Converts a text string to uppercase characters. Makeupper( string) Makeupper("abcd") returns "ABCD"
Mid: Returns a specified number of characters from the middle of a string. Mid( string,start,length) Mid("abcd",2,2) returns "bc"
Replace: Returns a text string in which a specified substring has been replaced with another substring a specified number of times. Replace(string, substring to replace, replacement substring) Replace("abc def","bc","xy") returns "axy def"
Right: Returns a specified number of characters from the right side of a string. Right( string,length) Right("abcd",2) returns "cd"
Trim:Returns a specified string without leading spaces or trailing spaces. Trim( string) Trim(" abcd ") returns "abcd"
TrimLeft: Returns a specified string without leading spaces. TrimLeft( string) TrimLeft(" abcd ") returns "abcd "
TrimRight: Returns a specified string without trailing spaces. TrimRight( string) TrimRight(" abcd ") returns " abcd"

Conversion Functions

Function/Return Type Syntax Range for Expression
ToBool: Boolean ToBool(expression) Any valid string or numeric expression.
ToDouble: Double ToDouble(expression) 1.7E +/- 308
ToLong: Long ToLong(expression) -2,147,483,648 to 2,147,483,647; fractions are rounded.
ToString: Text ToString(expression) Returns for ToString depend on the content of the expression.
ToLongLong: Integer ToLongLong -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ToEnumeration: Integer ToEnumeration -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Note: Because the Open Agent does not support 64-bit data types, the recommended range for this expression is -2,147,483,648 to 2,147,483,647.

Conversion Rules

When converting data types, observe the following rules:

Converting a Double to a Long

Decimals are truncated. Numbers outside the bounds of a Long are wrapped. For example, the Double number 49.6 is rounded down (i.e., .6 is truncated) to 49. The Double number -2147483649 is wrapped to the highest limit of a Long, which is +214748367.

Converting a String to a Double or Long

Conversion stops at the first unrecognized character, such as an alpha character. For a Long, decimals are truncated and numbers outside the bounds of a Long are wrapped. For example, "123.7 oranges" converts to Double "123.7" and Long "123".

Converting to a Boolean

Any non-zero numeric character, the text "true", or any text that converts to a number is converted to True. The zero character, the text "false", or any text that cannot convert to a number is converted to False.

Converting a Boolean to a Double or Long

True = 1 and False = 0.