CHR( ) function

Returns the character associated with the specified ASCII code.

Syntax

CHR(number)

Parameters

Name Type Description
number numeric A valid numeric expression between 1 and 255.

Output

Character.

Examples

Basic examples

Returns "A":

CHR(65)

Returns "1":

CHR(49)

Advanced examples

Adding the UK pound symbol (£) to each of the values in a currency field

Create a computed field that adds the pound symbol (ASCII code 163) before amounts in the Invoice_Amount field. The numeric Invoice_Amount field is first converted to a character field, and leading and trailing blank spaces are trimmed.

DEFINE FIELD Currency_UK COMPUTED CHR(163)+ALLTRIM(STRING(Invoice_Amount, 12))

Remarks

When to use CHR( )

Use the CHR( ) function to return the character associated with any ASCII code, including those characters that cannot be entered directly from a keyboard or displayed on screen. With CHR( ), you can search fields or records for the existence of these specific characters.

Referencing NUL

Referencing the ASCII NUL (null) character, CHR(0), may produce unpredictable results because it is used by Analytics as a text qualifier, and should be avoided if possible.

Related functions

CHR( ) is the inverse of the ASCII( ) function.

ACL Scripting Guide 14.1