Previous Topic Next topic Print topic


Assignment - ONSOURCE Pseudovariable

Purpose

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

Syntax

ONSOURCE() = string 

or

ONSOURCE = string

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

Parameters

string
An expression that is converted to a 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 ONSOURCE 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 ONSOURCE pseudovariable is valid only in the context of a CONVERSION ON-unit. In all other cases, the ONSOURCE pseudovariable is ignored.

Example:

DCL I FIXED BIN(15);
ON CONVERSION BEGIN;
   ONSOURCE() = '0'; 
END;

I = STRING VALUE; 
PUT LIST(I);

If STRING_VALUE contains an invalid character, use of the ONSOURCE pseudovariable in the above example resets STRING_VALUE to zero. Therefore, the program will display an integer value of 0.

Restrictions

None.

Previous Topic Next topic Print topic