Progress
Language Reference


CHR Function

Interfaces
OS
SpeedScript
All
All
Yes

Converts an integer value to its corresponding character value.

SYNTAX

CHR ( expression 
      [ , target-codepage [ , source-codepage ] ]
    ) 

expression

An expression that yields an integer value that you want to convert to a character value.

If the value of expression is in the range of 1 to 255, CHR returns a single character. This character might not be printable or might not display on certain terminals. For a value greater than 255 and less than 65535, the CHR function checks for a corresponding lead-byte value. If the integer value corresponds to a valid lead-byte, the CHR returns a double-byte character.

The CHR function returns a null string if the expression yields a value outside of the range 1 to 65534 or the expression yields a value in the range 256 to 65534 and the value does not correspond to a valid lead-byte.

target-codepage

A character-string expression that evaluates to the name of a code page. The name that you specify must be a valid code page name available in the DLC/convmap.cp file (a binary file that contains all of the tables that Progress uses for character management). If you supply a non-valid name, the CHR function returns a null string. Before returning a character value, the CHR function converts expression from source-codepage to target-codepage. The returned character value is relative to target-codepage. If you do not specify target-codepage, no code page conversions occur.

source-codepage

A character-string expression that evaluates to the name of a code page. The name that you specify must be a valid code page name available in the DLC/convmap.cp file. If you supply a non-valid name, the CHR function returns a null string. The source-codepage specifies the name of the code page to which expression is relative. The default value of source-codepage is the value of SESSION:CHARSET.

EXAMPLE

This procedure initializes the 26 elements of the letter array to the letters A through Z.

r-chr.p
DEFINE VARIABLE letter AS CHARACTER FORMAT "X(1)" EXTENT 26.
DEFINE VARIABLE I AS INTEGER.

DO I = 1 TO 26:
  letter[i] = CHR((ASC("A")) - 1 + i).
END.
DISPLAY SKIP(1) letter WITH 2 COLUMNS NO-LABELS
  TITLE "T H E  A L P H A B E T". 

NOTES

SEE ALSO

ASC Function, CODEPAGE-CONVERT Function, SESSION System Handle, STRING Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095