ContentsIndex PreviousNext

TRANSFORM Statement

IBM DOS/VS COBOL has a TRANSFORM statement with the following syntax:

     TRANSFORM  identifier-1  CHARACTERS FROM pattern-1 TO pattern-2

Each pattern is one of the following:

ZERO

ZEROS

ZEROES

SPACE

SPACES

QUOTE

QUOTES

LOW-VALUE

LOW-VALUES

HIGH-VALUE

HIGH-VALUES

nonnumeric-literal

identifier-2

Here identifier-2 must not be more than 255 characters long. If it is more than
255 characters long, the results in IBM DOS/VS COBOL are undefined; in ACUCOBOL-GT only the first 255 characters are used.

Each figurative constant (ZERO, ZEROS, ZEROES, SPACE, SPACES, QUOTE, QUOTES, LOW-VALUE, LOW-VALUES, HIGH-VALUE and HIGH-VALUES) is equivalent to a one-character nonnumeric literal containing the associated character. For example, ZERO is equivalent to'0' and HIGH-VALUE is equivalent to x"FF".

One of the following conditions must hold:

1. pattern-1 and pattern-2 are the same length;

2. pattern-1 contains more than one character and pattern-2 contains exactly one character.

The effect of the TRANSFORM statement on the contents of identifier-1 is undefined if neither of these conditions holds. The effect on the contents of identifier-1 is also undefined if pattern-1 contains duplicate characters. However, the statement finishes in a reasonable time and control passes normally to the next statement in any case.

At run time, every character in identifier-1 which matches a character in pattern-1 is replaced by the character in the corresponding position in pattern-2. If there is no corresponding position, because pattern-2 is shorter than pattern-1, then it is replaced by the sole character in pattern-2.