ONWSOURCE() = string
or
ONWSOURCE = string
The second syntax form can be used only when ONWSOURCE has been explicitly declared using the BUILTIN attribute.
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!
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.