ONWCHAR Function

Purpose

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

Syntax

ONWCHAR()

or

ONWCHAR

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

Description

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

The ONWCHAR 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

ONWCHR: PROC OPTIONS(MAIN);

 DCL I     FIXED BIN(15);
 DCL CSTR  CHAR(4);
 DCL WSTR  WCHAR(4);

 ON CONVERSION BEGIN;
     DCL BADCHAR WCHAR(1);
     PUT SKIP LIST("ON CONVERSION TRIGGERED");
     BADCHAR = ONWCHAR();
     PUT SKIP LIST (HEX(BADCHAR));
     STOP;
 END ;

 WSTR = '9941004200430044'WX;
 PUT SKIP LIST(HEX(WSTR));

 CSTR =  WSTR;     /* '9941'wx conversion error */
 PUT SKIP LIST(CSTR);
 END;

Will print:

9941004200430044
ON CONVERSION TRIGGERED
9941

Restrictions

None.