String Operations

The string operations are shown in the following table.

Table 71. String Operations
Operation Traditional Syntax Free-Form Syntax
Concatenate CAT (Concatenate Two Strings) + operator
Check CHECK (Check Characters) %CHECK (Check Characters)
Check Reverse CHECKR (Check Reverse) %CHECKR (Check Reverse)
Create %STR (Get or Store Null-Terminated String)
Replace %REPLACE (Replace Character String)
Scan SCAN (Scan String) %SCAN (Scan for Characters)
Scan and Replace %SCANRPL (Scan and Replace Characters)
Substring SUBST (Substring) %SUBST (Get Substring)
Translate XLATE (Translate) %XLATE (Translate)
Trim Blanks %TRIM (Trim Characters at Edges), %TRIML (Trim Leading Characters), or %TRIMR (Trim Trailing Characters)

The string operations include concatenation, scanning, substringing, translation, and verification. String operations can only be used on character, graphic, or UCS-2 fields.

The CAT operation concatenates two strings to form one.

The CHECK and CHECKR operations verify that each character in factor 2 is among the valid characters in factor 1. CHECK verifies from left to right and CHECKR from right to left.

The SCAN operation scans the base string in factor 2 for occurrences of another string specified in factor 1.

The SUBST operation extracts a specified string from a base string in factor 2. The extracted string is placed in the result field.

The XLATE operation translates characters in factor 2 according to the from and to strings in factor 1.

Note:
Figurative constants cannot be used in the factor 1, factor 2, or result fields. No overlapping in a data structure is allowed for factor 1 and the result field, or factor 2 and the result field.

In the string operations, factor 1 and factor 2 may have two parts. If both parts are specified, they must be separated by a colon. This option applies to all but the CAT, CHECK, CHECKR, and SUBST operations (where it applies only to factor 2).

If you specify P as the operation extender for the CAT, SUBST, or XLATE operations, the result field is padded from the right with blanks after the operation.

See each operation for a more detailed explanation.

When using string operations on graphic fields, all data in factor 1, factor 2, and the result field must be graphic. When numeric values are specified for length, start position, and number of blanks for graphic characters, the values represent double byte characters.

When using string operations on UCS-2 fields, all data in factor 1, factor 2, and the result field must be UCS-2. When numeric values are specified for length, start position, and number of blanks for UCS-2 characters, the values represent double byte characters.

When using string operations on the graphic part of mixed-mode character data, the start position, length and number of blanks represent single byte characters. Preserving data integrity is the user's responsibility.



[ Top of Page | Previous Page | Next Page | Contents | Index ]