A string expression is an expression that returns a value that is a hexadecimal string, EBCDIC string, or ASCII string.
<string expression>
──<string primary>─────────────────────────────────────────────────────► ►─┬───────────────────────────────────────────────────────┬────────────┤ │ ┌◄──────────────────────────────────────────────────┐ │ └─┴─<string concatenation operator>──<string primary>─┴─┘
<string concatenation operator>
──┬─ CAT ─┬────────────────────────────────────────────────────────────┤ └─ !! ──┘
<string primary>
──┬─<string constant>─────────────────┬────────────────────────────────┤ ├─<string variable>─────────────────┤ ├─<subscripted string variable>─────┤ ├─<string function designator>──────┤ ├─<string-valued library attribute>─┤ └─ ( ──<string expression>── ) ─────┘
<string constant>
──┬─ EMPTY ───────────────────────┬────────────────────────────────────┤ ├─<EBCDIC string constant>──────┤ ├─<ASCII string constant>───────┤ └─<hexadecimal string constant>─┘
<EBCDIC string constant>
──┬─ EMPTY8 ────────────────┬──────────────────────────────────────────┤ └─<EBCDIC string literal>─┘
<ASCII string constant>
──┬─ EMPTY7 ────────────────────────────────────────┬──────────────────┤
│ ┌◄────────────────────────────────────────────┐ │
└─┴─┬──────────────┬─ " ──<ASCII string>── " ─┬─┴─┘
├─<ASCII code>─┘ │
├─ 47 ──┬─ " ──<hexadecimal string>── " ──┤
├─ 470 ─┘ │
├─ 27 ──┬─ " ──<quaternary string>── " ───┤
├─ 270 ─┘ │
├─ 17 ──┬─ " ──<binary string>── " ───────┘
└─ 170 ─┘
<hexadecimal string constant>
──┬─ EMPTY4 ──────────────────────────────────────┬────────────────────┤
│ ┌◄──────────────────────────────────────────┐ │
└─┴─┬─ 4 ──┬─ " ──<hexadecimal string>── " ─┬─┴─┘
├─ 40 ─┘ │
├─ 24 ──┬─ " ──<quaternary string>── " ─┤
├─ 240 ─┘ │
├─ 14 ──┬─ " ──<binary string>── " ─────┘
└─ 140 ─┘
<string variable>
──<string identifier>──────────────────────────────────────────────────┤
<subscripted string variable>
┌◄───── , ────┐ ──<string array identifier>── [ ─┴─<subscript>─┴─ ] ───────────────────┤
<string-valued library attribute>
──<library attribute designator>── . ──────────────────────────────────► ►─<string-valued library attribute name>───────────────────────────────┤
A string expression that can be fully evaluated at compilation time.
In the syntax for EBCDIC string constant, ASCII string constant, and hexadecimal string constant, the string codes determine the interpretation of the characters between the quotation marks (") and have no effect on the justification of a string. A string is always left-justified; therefore, any 0 (zero) in a string code is ignored.
The <EBCDIC code> construct is optional in an EBCDIC string constant containing an EBCDIC string only if the default character type is EBCDIC. The <ASCII code> construct is optional in an ASCII string constant containing an ASCII string only if the default character type is ASCII. For more information, refer to String Code and Default Character Type.
The reserved words EMPTY8, EMPTY7, and EMPTY4 represent null strings of the character types EBCDIC, ASCII, and hexadecimal, respectively. The reserved word EMPTY represents a null string of the default character type.
For more information about string-valued library attributes, refer to Library Attributes.
String Concatenation
The operators CAT and !! are used to concatenate two strings. The concatenation of two strings yields a new string whose length is the sum of the lengths of the two original strings, and whose value is formed by joining a copy of the second string immediately onto the end of a copy of the first string.
Only strings of the same character type can be concatenated.
If more than one string primary is used in a concatenation operation, the string primaries are evaluated from left to right.
No more than 256 characters can appear between one pair of quotation marks in a string constant; however, as many as 4095 characters can appear in an EBCDIC string constant, ASCII string constant, or hexadecimal string constant.
Examples of String Expressions
8"ABCD123" % result = ABCD123
""WHY"48"6F"""" % result = "WHY?"
EMPTY8 % result =
S2 !! S3
"AC" !! S2 !! "123"
S1 !! TRANSLATE(S2,HEXTOEBCDIC)
HEAD(S,ALPHA)
TAIL(S,NOT "-")
REPEAT("ABC",3)
STRING(256,*)
TAKE(S,2)
DROP(TAKE(S,4),2)
TRANSLATE(S,HEXTOEBCDIC)
