The concatenate operator, || or !!, is used to concatenate two strings to produce a string result.
The compound assignment operator ||= is also supported. The following two statements are equivalent:
s = s || s1; s ||= s1;
If both operands are bit strings, the concatenate operator produces a bit-string result.
If both operands are Widechar, the concatenate operator produces a Widechar result.
If both operands are Graphic, the concatenate operator produces a Graphic result.
Otherwise, if one operand is Widechar, the other operand is promoted to Widechar according the Conversion rules described in Data Type Conversions. If one operand is Graphic and the other operand is neither Graphic nor Widechar, the other operand is promoted to Graphic according the Conversion rules described in Data Type Conversions.
Otherwise, both operands are converted to character strings, and the concatenate operator produces a character-string result.
For example:
C = ‘004100420043’Wx; /* wide ‘ABC’ */ D = ‘DEF’; /* char ‘DEF’ */
C || D produces WIDECHAR string containing 0x004100420043004400450046 (length = 6).
The length of the string result is the sum of the lengths of the converted operands, as shown in the following example:
A = 'ABC'; B = 'XYZ';
In the previous example, A | | B produces 'ABCXYZ', and A | | 5 produces 'ABC 5'. The conversion rule that produces the blanks is explained in the topic Arithmetic to Character-String Conversion in the chapter Data Type Conversions.