Changing case (UPPER-CASE, LOWER-CASE)
You can use the UPPER-CASE
and LOWER-CASE
intrinsic
functions to easily change the case of alphanumeric, alphabetic, or
national strings.
About this task
01 Item-1 Pic x(30) Value "Hello World!".
01 Item-2 Pic x(30).
. . .
Display Item-1
Display Function Upper-case(Item-1)
Display Function Lower-case(Item-1)
Move Function Upper-case(Item-1) to Item-2
Display Item-2
The code above displays the following messages on the system logical output device:
Hello World!
HELLO WORLD!
hello world!
HELLO WORLD!
The DISPLAY
statements do not change
the actual contents of Item-1
, but affect only how
the letters are displayed. However, the MOVE
statement
causes uppercase letters to replace the contents of Item-2
.
The conversion uses the case mapping that is defined in the current locale. The length of the function result might differ from the length of the argument.