Progress
Report Builder
User’s Guide


- Concatenation

Produces a character value by joining two character strings or expressions, after trimming any trailing spaces from the first expression. Whether you should use the + or the - concatenation operator depends on whether you want to preserve trailing spaces. However, it is not always immediately obvious what will be considered a ’trailing’ space: see the first Example, below.

SYNTAX

expression + expression 

expression

An expression whose value is a character string.

EXAMPLE

This expression formats the city, state, and postal code for an address:

City + ", " + State + "  " + Postal-Code 

But if there are any trailing spaces in the City or State fields, the result may look odd:

Bedford               , Massachusetts            01730 

Using the ’-’ concatenation operator will remove trailing spaces. However, incautious use of ’-’ may also give an undesired result. Substituting ’-’ for ’+’ in the example expression above would produce

Bedford,Massachusetts01730 

with no spaces at all, because even the literal spaces would be seen as trailing spaces and removed once they’d been appended.

To solve the problem, using the ’+’ operator behind any spaces you wish to preserve:

City - ", " + State - " " + Postal-Code 

will produce the result desired:

Bedford, Massachusetts 01730 

NOTE

If any of the string values you concatenate is UNKNOWN, then the result is the UNKNOWN value (?). This might lead to unexpected results if a field used in an expression is not mandatory. For example, you might have fields for a person’s first name, last name, and middle initial. You might combine these into a full name with an expression like the following:

First-Name + " " + Mid-Init + " " + Last-Name 

If Mid-Init is not a mandatory field, then in some records Mid-Init can be set to UNKNOWN (?). If so, the result of the expression is UNKNOWN. You can avoid this by using the following expression:

First-Name + " " + (IIF(Mid-Init <> ?, Mid-Init + ". ", "") + Last-Name 

which causes the middle substring to be either Mid-Init with a space appended, or empty, depending on whether Mid-Init evaluates as not-UNKNOWN.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095