C Code

Concatenating Data. Concatenates the data in two or more attributes. Literals can also be included in the concatenation.

Format

Cexpression1 ch  expression2 [ch expression3…]

Parameter(s)

expression

Any attribute number, any literal string enclosed in single or double quotes or backslashes, or an asterisk. An asterisk specifies the result generated by a previous conversion or correlative operation.

ch

Any nonnumeric character with the exception of the semicolon (;), which specifies that no separation character is to be used. No spaces should be included between expression and ch.

For example, in the CUSTOMERS file, LAST-NAME is Attribute 2 and FIRST-NAME is Attribute 1. The Attribute Definition item FULL-NAME defines a new attribute that concatenates the last and first names (in that order). This is done by including this C correlative in line 8 of the Attribute Definition item FULL-NAME:

C2 ; ', ' ; 1

The above example concatenates data contained in Attribute 2 with data contained in Attribute 1, separating the two elements with a comma followed by one space. If a customer’s last name is Morris and first name is Steven, the correlative produces the result:

MORRIS, STEVEN

On the other hand, the C code:

C1  2

produces the result:

STEVEN  MORRIS

In the preceding line, a space must be entered between the two expressions as a separator.

In the next example, a C correlative builds a part number from the three pieces of data contained in Attributes 3, 2, and 4 of an inventory file. Each part specification begins with the literal string AZ and uses hyphens as separation characters.

Here is the Attribute Definition item for PART#:

0001 A

0002 0

0003 Part No.

0004

0005

0006

0007

0008 C'AZ';3-2-4

0009

0010 13

The literal string AZ is enclosed in quotes. The semicolon specifies that no space (or other separator) is to be used between the literal expression and the data of Attribute 3. Values from Attribute 3, Attribute 2, and Attribute 4 are then specified, to be separated from each other by hyphens.

Here are lines 2, 3, and 4 of the item SERVO in the PARTS file:

002 35

003 250

004 1002

When the C correlative is applied to the data in this item and output in a report, it looks like this:

PARTS.....      Part No......

SERVO           AZ250-35-1002

END OF LIST

>

A C correlative creates the part number from the literal string AZ and three attributes.

NOTE

Any Attribute Definition item containing a C correlative should specify an attribute number of zero in Attribute 2. If any other attribute number is used and that attribute contains a null value, the concatenation is not performed.

See Also

Deriving Data from Attributes

B Code

Extracting Data

S Code

Testing Data

Manipulating Existing Data