ContentsIndexPreviousNext

5.2.3 Reference Modification

Reference modification is a syntax for referencing a portion (substring) of a data item. The reference defines a temporary, unique data item. Reference modification may be used anywhere in the Procedure Division.


Note: This manual entry includes code examples and highlights for first-time users following the General Rules section.
General Format

data-name ( leftmost-position : [length] )

Syntax Rules

1. Leftmost-position and length are arithmetic expressions.

2. Unless otherwise specified, reference modification is allowed anywhere a data item of the class alphanumeric is permitted.

3. Data-name may be qualified or subscripted. Reference modification is done after both qualification and subscripting.

General Rules

1. Each character of the data item referenced by data-name is assigned an ordinal number starting at one for the leftmost position and incrementing by one for each character in the item.

2. Reference modification for an operand is evaluated as follows:

a) If subscripting is specified, the reference modification is evaluated immediately after the evaluation of the subscripts.

b) If subscripting is not specified, the reference modification is evaluated at the time subscripting would have been evaluated if subscripts had been specified.

3. Reference modification creates a unique data item which is a subset of data-name. This unique data item is defined as follows:

a) The evaluation of leftmost-position specifies the leftmost character of the unique data item relative to the start of data-name. Evaluation of leftmost-position must result in an integer greater than zero and less than or equal to the number of characters contained in data-name.

b) The evaluation of length specifies the size of the unique data item. The evaluation of length must result in a positive integer. The sum of leftmost-position and length must be less than or equal to the number of characters contained in data-name, plus one. If length is not specified, the unique data item extends through the rightmost character of data-name.

4. The unique data item is considered an elementary data item without the JUSTIFIED clause. It has the same class and category as data-name except that categories numeric, numeric edited, and alphanumeric edited are treated as class and category alphanumeric.

More:

Code Examples

Highlights for First-Time Users