Previous Topic Next topic Print topic


ONGSOURCE Function

Purpose

Returns a graphic string whose value is the context of the field that was being processed when the CONVERSION condition was signaled.

Syntax

ONGSOURCE()

or

ONGSOURCE

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

Description

The ONGSOURCE function returns a graphic string whose value is the context of the field that was being processed when the CONVERSION condition was signaled.

The ONGSOURCE 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.

The returned value is a varying-length graphic string.

Examples

This example assumes Codepage of 932 - SHIFT-JIS - Japanese.

ONGSRC: PROC OPTIONS(MAIN);

DCL I     FIXED BIN(15);
DCL CSTR  CHAR(4);
DCL GSTR  GRAPHIC(4);

ON CONVERSION BEGIN;
     DCL BADSTR  GRAPHIC(4);
     PUT SKIP LIST("ON CONVERSION TRIGGERED");
     BADSTR = ONGSOURCE();
     PUT SKIP LIST (HEX(BADSTR));
     ONGSOURCE() = 'Err!';
END ;

GSTR = '8989826182628263'GX;
PUT SKIP LIST(HEX(GSTR));

CSTR =  GSTR;     /* '8989'gx conversion error */

CSTR =  GSTR;
PUT SKIP LIST(CSTR);
END;

Will print:

8989826182628263
ON CONVERSION TRIGGERED
8989826182628263
ON CONVERSION TRIGGERED
8989826182628263
Err!

Restrictions

None.

Previous Topic Next topic Print topic