Joins two character strings or expressions. The data type of the returned value matches the data type of the expressions passed to the function. When one expression is LONGCHAR and the other CHARACTER, the result is a LONGCHAR.
Syntax
expression + expression
expression
An expression whose value is a character string. If any expression is a LONGCHAR, the result is a LONGCHAR. Also, the result converts to the code page of the expression on the left.
Example
The r-conc.p procedure prints mailing labels. It uses the concatenation operator (+) to ensure that the third line of each label shows the city and state separated by a comma and a space. The FORMAT x(16) is specified to provide room for up to 16 characters in the result of the concatenation. If a FORMAT is not given, then the AVM displays only the first eight characters of the result since x(8) is the default format for a character expression.
r-conc.p
FOR EACH Customer NO-LOCK:
DISPLAY SKIP(1) Customer.Name SKIP Customer.Address SKIP
Customer.City + ", " + Customer.State FORMAT "x(16)" Customer.Country
Customer.PostalCode SKIP(2).
END.
This is a label produced by this procedure:
Notes
If any of the string values you concatenate is the Unknown value (?), 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:
If minit is not a mandatory field, it might be set to the Unknown value (?) in some records. If so, then those records are displayed as the Unknown value (?). You can avoid this by using conditional code. For example: