C Code - Concatenation
The C code concatenates attributes, enclosed literals, and the results of a previous operation with single-character separators.
Input Conversion
Input conversion does not invert. It simply applies the concatenation to the input data.
Syntax
C{;}n{xn}...
Syntax Elements
; Is an optional semicolon after C that allows the processor to handle C codes conforming to the SMA standard. It has no other function.
n Can be one of the following:
- An attribute number (AMC).
- A literal enclosed in single quotes, double quotes, or backslashes.
- An asterisk (*) to specify the last generated value of a previous operation.
x Is a character to be inserted between the concatenated elements. Any single character, including a blank, is valid except the system delimiters (value, subvalue, attribute, start buffer, and segment marks).
The semicolon is a reserved symbol that can be used as character x. It means no separation character is to be used.
Multidigit AMCs
If you forget to insert an x character before a multidigit AMC, the processor uses the first digit of the AMC as the insert character. It then uses the remaining digits as the AMC.
Data definition item AMC
If the AMC in attribute 2 of the data definition item points to a null attribute, the processor ignores the C code specification and outputs a null value.
Unless you wish to take advantage of this, you should always put a zero in attribute 2 of a data definition item that uses the C code. Zero is the AMC of the item-id: if you put a zero in attribute 2, the only way the AMC could be pointing at a null attribute is if the item-id were null.
Other Methods
See the descriptions of the conversion codes A, F, FS and their variants for other concatenation methods.
C Code - Example
The dictionary of file C.TEST contains the following data definition items:
CAT1 CAT2 CAT3
001 A A A
002 0 0 7
003
004
005
006
007 C2;'55'=1/4 C6;3
008 C1+3
009 L L L
010 15 10 10
The data section of C.TEST contains the following data items:
TEST.1 TEST.2
001 ABC AAA
002 DEF BBB
003 GHI CCC
004 JKL DDD
005 MNO EEE
006 FFF
007 GGG
008 123 XXX
CAT3 has an AMC of 7 in attribute 2 and that attribute 7 in data item TEST.1 contains null. This means that a null value is output as shown on the first line of the report below. Note that attribute 6 of TEST.1 contains a null but that the C code processor uses the null without affecting any other processing.
:LIST C.TEST CAT1 CAT2 CAT3 PAGE 1 C.TEST.... CAT1........... CAT2...... CAT3...... TEST.1 DEF55=ABC/JKL GHI TEST.2 BBB55=AAA/DDD FFFCCC AAA+CCC 2 ITEMS LISTED