ONCHAR Function

Purpose

Returns a character string of length 1, containing the character that caused the CONVERSION condition to be signaled.

Syntax

ONCHAR()

or

ONCHAR

The second syntax form can be used only when ONCHAR has been explicitly declared with the BUILTIN attribute.

Description

The ONCHAR function returns a character string of length 1, containing the character that caused the CONVERSION condition to be signaled.

The ONCHAR function can be used in an ON-unit established for a CONVERSION condition. It can also be used for an ERROR ON-unit that obtains control as the result of unsuccessful error correction in the CONVERSION ON-unit.

Examples

DCL I FIXED BIN(15); 
ON CONVERSION BEGIN; 
 PUT LIST ('Incorrect character is:',ONCHAR());
END;

I = '34Z9';

In the above example, the program will display the character "Z" that caused the conversion error to occur.

Restrictions

None.