HP 3000 Manuals

REVERSE Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

REVERSE Function 

The REVERSE function returns a character string of exactly the same
length as parameter-1 and whose characters are exactly the same as those
of parameter-1, except that they are in reverse order.  The function type
is alphanumeric.

Syntax 

     FUNCTION REVERSE (parameter-1)

Parameters 

parameter-1           Must be class alphabetic or alphanumeric and must
                      be at least one character in length.

Return Value 

If parameter-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
parameter-1.

Example 

     77  CITY        PIC X(7) VALUE "CHICAGO".
          :
     DISPLAY CITY.
     DISPLAY FUNCTION REVERSE (CITY).

The above example displays the following:

     CHICAGO
     OGACIHC



MPE/iX 5.0 Documentation