Assignment - ONWCHAR Pseudovariable

Purpose

Sets the current value of the ONWCHAR built-in function.

Syntax

ONWCHAR() = string

or

ONWCHAR = string

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

Parameters

string
An expression that is converted to a wide character string of length 1.

Description

The ONWCHAR pseudovariable is used to replace the invalid wide character that caused the CONVERSION condition to be raised. This new character is used when the conversion is attempted again.

The ONWCHAR pseudovariable is valid only in the context of a CONVERSION ON-unit. In all other cases the ONWCHAR pseudovariable is ignored.

Example

ONWCHR: PROC OPTIONS(MAIN);

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

 ON CONVERSION BEGIN;
     PUT SKIP LIST("ON CONVERSION TRIGGERED");
     ONWCHAR() = '0030'WX;
 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
0BCD

Restrictions

None.