9.182 REVERSE

Note: Built-In Function Rules     Usage Options

Reverses a text string.

Important note for DBCS: This Built-In function is DBCS unaware. To reverse a string containg DBCS characters so that the DBCS characters do not get corrupted you must use RDMLX  .Reverse instrinsic

Arguments

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Req

String to reverse

1

Unlimited

 

 

 

Return Values

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Req

Reversed string

1

Unlimited

 

 

 

Examples

Example 1: Reverse a text string input from user

DEFINE     FIELD(#INTEXT)  TYPE(*CHAR) LENGTH(20)

DEFINE     FIELD(#OUTEXT)  TYPE(*CHAR) LENGTH(20)

**********

REQUEST    FIELDS(#INTEXT)

USE        BUILTIN(REVERSE) WITH_ARGS(#INTEXT) TO_GET(#OUTEXT)

DISPLAY    FIELDS(#OUTEXT)

Example 2: Reverse a known text string

DEFINE     FIELDS(#OUTEXT)  TYPE(*CHAR) LENGTH(10)

**********

USE        BUILTIN(REVERSE) WITH_ARGS('''ti esreveR''')

           TO_GET(#OUTEXT)

DISPLAY    FIELDS(#OUTEXT)