Previous Topic Next topic Print topic


Reference Modification

Reference modification defines a unique data item by specifying an identifier, a leftmost position and a length.

General Format

identifier-1 ( leftmost-position : [length] )

Syntax Rules

  1. Identifier-1 must reference a data item that is one of the following:
    • An elementary item of class alphanumeric or national
    • A numeric item of usage display
    • A group item
    Note: Identifier-1 must not be an individual boolean data item or a group item defined by the GROUP-USAGE BIT clause.
  2. Leftmost-position and length must be arithmetic expressions.
  3. Unless otherwise specified, reference modification is allowed anywhere an identifier referencing a data item of the class alphanumeric or national is permitted.
  4. Identifier-1 must not include reference-modification.
  5. If identifier-1 is a function-identifier, it must reference an alphanumeric or national function.

General Rules

  1. Leftmost-position represents an alphanumeric position or national position when identifier-1 references an alphanumeric or national data item, respectively.
  2. Each position of the data item referenced identifier-1 is assigned an ordinal number incrementing by one from the leftmost position to the rightmost position. The leftmost position is assigned the ordinal number one. If the data description entry for identifier-1 contains a SIGN IS SEPARATE clause, the sign position is assigned an ordinal number within that data item.
  3. If the data item referenced by identifier-1 is explicitly or implicitly described as usage DISPLAY and the category is numeric,

    OSVSVSC2MF external floating-point,

    numeric edited, alphabetic, or alphanumeric edited, it is operated upon for purposes of reference modification as if it were redefined as an alphanumeric data item of the same size as the data item referenced by identiifer-1.

  4. Reference modification for an operand is evaluated as follows:
    1. If subscripting is specified for the operand, the reference modification is evaluated immediately after evaluation of the subscripts. If an ALL subscript is specified for an operand, the reference-modifier is applied to each of the implicitly specified elements of the table.
    2. If subscripting is not specified for the operand, the reference modification is evaluated at the time subscripting would have been evaluated if subscripts had been specified.
    3. If reference modification is specified in a function reference, the reference modification is evaluated immediately after evaluation of the function.
    4. If reference modification is specified in an object property reference, the reference modification is evaluated immediately after evaluation of the object property.
  5. Reference modification creates a unique data item that is a subset of the data item referenced by identifier-1. This unique data item is defined as follows:
    1. The evaluation of leftmost-position specifies the ordinal position of the leftmost character of the unique data item in relation to the leftmost character of the data item referenced by identifier-1. Evaluation of leftmost-position must result in a positive nonzero integer less than or equal to the number of positions in the data item referenced by identifier-1.

      VSC2MF The results are rounded if the expression is in floating-point, and truncated if the expression is in fixed-point.

    2. The evaluation of length specifies the size in characters of the data item to be used in the operation. The evaluation of length must result in a positive nonzero integer. The sum of leftmost-position and length minus the value one, must be less than, or equal to, the number of characters in the data item referenced by identifier-1. If length is not specified, the unique data item extends from and includes the character identified by leftmost-position, up to and including the rightmost character of the data item referenced by identifier-1.

      VSC2MF The results are rounded if the expression is in floating-point, and truncated if the expression is in fixed-point.

      Note: There is no check that the evaluation of leftmost-position and length produce valid values. If these evaluations do not conform to the restrictions stated in this rule, the result is undefined and other data items may be corrupted.
  6. The unique data item is considered an elementary data item without the JUSTIFIED clause. The unique data item has the same class, category and usage as that defined for the data item referenced by identifier-1, except that:
    • The categories numeric, numeric edited, alphanumeric edited

      OSVSVSC2MF and external floating-point

      are considered class and category alphanumeric

    • ISO2002MF The category national-edited is considered class and category national.
  7. OSVS  If the OSVS Compiler directive is set, reference modification cannot be used in conditional expressions (see the topic Conditional Expressions).
Previous Topic Next topic Print topic