Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

REVERSE - Reverse order of string characters

The REVERSE function returns a character string of exactly the same length as argument-1 and whose characters are exactly the same as those of argument-1, except that they are in reverse order.
The type of this function depends upon the argument types as follows:

Argument type

Function type

alphabetic
alphanumeric
national

alphanumeric
alphanumeric
national

Format


FUNCTION REVERSE (argument-1)


Arguments

  1. argument-1 must be class alphabetic, alphanumeric or national and must be at least one character in length.

  2. argument-1 must not be defined in the ANY LENGTH clause.

Returned values

  1. If argument-1 is a character string of length n, the returned value is a character string of length n such that for 1 <= j <= n, the character in position j of the returned value is the character from position n j + 1 of argument-1.

  2. The error default value is a space.

Example 9-40

...
DATA DIVISION.
WORKING-STORAGE SECTION.
01  REV PIC X(17) VALUE "never odd or even".
01  RES PIC X(17).
PROCEDURE DIVISION.
P1 SECTION.
MAIN.
    MOVE FUNCTION REVERSE (REV) TO RES.
    DISPLAY RES UPON T.
    STOP RUN. 

Result:               neve ro ddo reven