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 variables Book.title and Book.author contain the texts "Gone with the Wind" and "Margaret Mitchell", respectively.

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

Book.price * 100

The following table provides an overview of the most commonly used sub-expression types. For a complete overview of all available sub-expression types, see the reference documentation on expressions.

Table 1. Commonly Used Sub-Expression Types

Sub-Expression Type

Notation

Description

Text Constant

"text" or >>text<<

Evaluates to the specified text, e.g. "Margaret Mitchell", or >>Margaret Mitchell<<.

Variables

variablename.attributename

Evaluates to the value of the specified variable, e.g. "Book.author" might evaluate to "Margaret Mitchell".

Current URL

URL

Evaluates to the URL of the current page.

Subpattern Match

$n

Evaluates to the text matched by subpattern in an associated pattern (if any). For example, this is used in the Advanced Extract data converter, as shown below. $0 evaluates to the text matched by the entire pattern.

Function

func(args)

Evaluates the specified function by passing it the specified arguments and converting its result to a text.

Note that you can specify a text constant using either the quote notation or the >>text<< notation, for example "Margaret Mitchell" or >>Margaret Mitchell<<. If you use the quote notation, and you want a quote character to appear inside the text, you have to write it as two quote characters. For example, write "This is some ""quoted"" text" to get the text "This is some "quoted" text". If you use the >>text<< notation, anything can appear inside the text, except ">>" and "<<". Thus, you can write quotes directly, as in >>This is some "quoted" text<<. The >>text<< notation is useful for long texts that contain many quote characters, such as HTML.

The following table shows the most commonly used functions in expressions.

Function

Description

toLowerCase(arg)

Converts the argument to lowercase.

round(arg)

Rounds the argument to the nearest integer.

For example, the expression "The discount is " + round((Item.oldPrice - Item.newPrice) / Item.oldPrice) + "%." evaluates to "The discount is 10%." when the item's old price is $99.95 and the new price is $89.95.