Expressions

An expression typically evaluates to a text. For example, the expression "The author of the book " + Book.title + " is " + Book.author + "." evaluates to the text "The author of the book Gone with the Wind is Margaret Mitchell.", if the attributes title and author of the Book variable contain the texts "Gone with the Wind" and "Margaret Mitchell", respectively.

You can also do numeric calculations within the expression. For example, if the attribute Book.price contains the price of a book, you can multiply it by 100 using the following expression:

Book.price * 100

Depending on where the expression occurs, an input text may be available for use in the expression. You can refer to this input text in the expression using the INPUT notation. For example, if the input text is "The time is " and you want to add the current time, you can use this expression:

INPUT + time(now())

Expression Types

Expression Type

Notation

Description

Examples

Constant

"text"

A fixed text.

You can use the backslash character (\) to enter special characters:

\n for line break

\r for carriage return

\f for form document

\t for horizontal tab

\b for backspace

\" for double quote

\' for single quote

\\ for backslash itself

\uxxxx for the unicode character with encoding xxxx, where xxxx is four hexadecimal digits.

"This is some \"quoted\" text."

"This a text with line break\n, tab \t and a unicode \u0035 character"

Constant

>>text<<

A fixed text. This notation can contain anything, including quote characters, except the end symbol (<<). The backslash (\) character cannot be used to enter special characters.

>>This is some "quoted" text.<<

Variables

variable.attribute

variable

The value of a variable. If the variable is a complex type, an attribute name must also be supplied.

Book.title

Integer

Input Text

INPUT

The input text, if any, to the expression.

INPUT

Concatenation

expr1 + expr2

The concatenation of the two expressions expr1 and expr2.

"Title:" + Book.title

Subpattern Match

$n

If n > 0, the text that matches subpattern n in the pattern. If n = 0, the text that matches the entire pattern.

Note: This expression has meaning only if there is a pattern associated with the expression.

$1

Numeric Expression

Operators: +, -, *, /, %

The result of a numeric expression.

Book.price * 100

Boolean Expression

Operators: && (and), || (or)

The result of a boolean expression.

performTransactions && Book.price < 30

Conditional Expression

condition ? expr1 : expr2

If condition evaluates to true, the value of expr1 is used; otherwise the value of expr2 is used.

Book.price < 30 ? "cheap" : "expensive"

Equality

Operators: == (equal to), != (not equal to)

These operators work on operands of all types, but the type of the operands must be the same. For example, you cannot compare a Number to an Integer.

true == false

style != "none"

Relational

Operators: < (less than), <= (less than or equal to), > (greater than), >= (greater than or equal to)

Relational operators determine if one operand is less than or greater than another operand.

The operands must be numbers, that is of type Integer or Number. The types of the operands in an expression must be the same.

0 < 1

1.0 >= 0.0

Function

func(expr)

The function func applied to the result of the expression expr. See the Functions section that follows this table for the available functions.

capitalize(Book.title)

Current URL

URL

The current URL.

URL

Current Window

WINDOW

The unique ID of the current window.

WINDOW

Robot Name

Robot.name

The name of the robot.

Robot.name

Execution ID

Robot.executionId

The current execution ID of the robot.

Robot.executionId

Execution Errors

Robot.executionErrors

The execution errors encountered in the previous branch of the nearest Try step.

Robot.executionErrors

Note The >>text<< notation for a text constant is useful to specify a long text that contains many quote characters, such as HTML. Using the >>text<< notation, you can use the text as is, and simply place the >> and << symbols around it. If you use the "text" notation, you have to replace all quote characters in the text with two consecutive quote characters.

Functions

Function Description

abs(arg)

Returns the absolute value of the number.

base64Decode(arg)

Decodes Base64 encoded data.

base64Encode(arg)

Encodes binary data with Base64 encoding.

binaryToText(data[, encoding])

Decodes binary data into text. Uses the specified encoding if present, or otherwise defaults to UTF-8 encoding.

capitalize(arg)

Makes the first letter of every word upper case and all other letters lower case.

ceil(arg)

Rounds the number up to the nearest integer.

collapseSpaces(arg)

Makes sure there are no two consecutive spaces.

contains(source, key)

Returns whether the source contains the specified key.

date()

Returns the current date in standard date format (yyyy-mm-dd).

day(args)

Returns the day of month of the date given as an argument.

endsWith(source, key)

Returns true if the source string ends with the specified key, or false otherwise.

excelColStringToNumberFunction

Converts a string from an Excel spreadsheet to a number.

excelNumberToColStringFunction

Converts a number to a string in an Excel spreadsheet.

floor(arg)

Rounds the number down to the nearest integer.

guid()

Returns a randomly generated, globally unique ID (GUID).

hexDecode(arg)

Decodes hex encoded data.

hexEncode(arg)

Encodes binary data with hex encoding.

indexOf(source, key)

Returns the first index of the key in the source, or -1 if not found.

length(arg)

Counts the number of characters in the text, or the number of bytes if given binary data.

max(a, b)

Returns the greater of the two numbers.

md5(arg)

Computes the MD5 checksum of the binary data given as an argument.

min(a, b)

Returns the smallest of the two numbers.

month(args)

Returns the month of the date given as argument.

now()

Returns the current date and time.

random()

Returns a random number between 0 and 1.

removeSpaces(args)

Removes all white space characters in the argument, such as SPACE, \t, \n.

replacePattern(source, pattern, newText)

Replaces every occurrence of the pattern "pattern" in text "source" with the text "newText". The pattern match is case insensitive.

replaceText(source, oldText, newText)

Replaces every occurrence of the text "oldText" in the text "source" with the text "newText". The match with "oldText" is case insensitive.

resolveURL(arg)

Converts a URL from relative to absolute using the current URL.

round(arg)

Rounds to the nearest integer.

shortTime(arg)

Returns the time without fractional seconds (hh:mm:ss) for the date given as an argument.

substring(source, startIndex)

Returns the portion of the source string starting at the startIndex and up to the end of the source string, with the first character of the string being at index 0.

substring(source, startIndex, endIndex)

Returns the portion of the source string starting at the startIndex and up to the endIndex, with the first character of the string being at index 0.

startsWith(source, key)

Returns true if the source string starts with the specified key, or false otherwise.

textToBinary(text[, encoding])

Encodes text to binary data. Uses the specified encoding if present, or otherwise defaults to UTF-8 encoding.

time(arg)

Returns the time (hh:mm:ss.fff) for the date given as an argument.

toInteger(args)

Converts the text to an integer. This can be useful if you want to include it in calculations.

toNumber(args)

Converts the text to a floating-point number. This can be useful if you want to include it in calculations.

toLowerCase(arg)

Converts all of the characters in the text to lowercase.

toUpperCase(arg)

Converts all of the characters in the text to uppercase.

trim(arg)

Removes all space from both ends of the text.

urlDecode(arg)

Decodes the URL encoded text.

urlEncode(arg)

URL encodes the text.

weekday(arg)

Returns the name of the weekday (in English) for the date given as an argument.

year(args)

Returns the year of the date given as an argument.