Previous Topic Next topic Print topic


Assignment - ONWSOURCE Pseudovariable

Purpose

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

Syntax

ONWSOURCE() = string 

or

ONWSOURCE = string

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

Parameters

string
An expression that is converted to a wide character string. If the length of the field that caused the CONVERSION condition is greater than the length of string, string is padded with blanks. If the length of the field is less than the length of string, string is truncated to match the field length.

Description

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

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

Example:

ONWSRC: 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");
     ONWSOURCE() = 'Err!';
 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
Err!

Restrictions

None.

Previous Topic Next topic Print topic