Assignment - STRING Pseudovariable

Purpose

Assigns the converted value of the expression e to r, as if r were a string variable whose length is the total number of characters or bits in the variable identified by r.

Syntax

STRING(r)=e;

Parameters

r
A reference to a string, array, or structure variable that:
  • r is not union or structure containing unions
  • if r is a scalar, r must be a character or bit string. If r is a character string, it must be of type char, char varying, or picture.
  • if r is a structure, it must comprised of all type bit, or all of type char, char varying, and/or picture.
e
Any valid expression.

Description

The STRING pseudovariable interprets an appropriate reference as a reference to a fixed-length string.

The STRING assignment assigns the converted value of the expression e to r, as if r were a string variable whose length is the total number of characters or bits in the variable identified by r. The STRING assignment can modify an entire aggregate with a single string assignment or assign the aggregate to a pictured variable as if it were a character-string variable.

Example

DECLARE A(5) CHARACTER(1);
   .
   .
   .
STRING(A) = 'ABCDE';

After the previous assignment, A (1) has the value of 'A' , A (2 ) has the value of 'B', and so forth.

Restrictions

Arrays containing char varying data items when applied as the argument to the STRING pseudo variable is not currently supported.