INITIALIZE

FUNCTION

To assign initial values to program variables.

FORMAT

      INITIALIZE [DATA] (Reference [,Reference]...);

 

The reference may be a field reference or a generic reference. 

 

You use INITIALIZE to set, or reset, fields to their default values. For example: -

      INITIALIZE (CustF.*);

This sets every field in CustF to the value given in its VALUE clause. If there is no value clause then numeric fields are set to zero, string fields to blank, etc.  See below for a list by type of default values. Also, for TYPE(SQL) fields all fields will be set to NULL unless they are defined NOTNULL.

Default Values

If there is a VALUE clause, then the field’s value will be set to this.

 

ElseIf there is no VALUE clause, but there is a VALIDVALUES clause, then the field will be set to the first value in the list

 

Else field values will be set as following: -

Numeric fields: BIGINT, INTEGER, SMALLINT, DECIMAL, MONEY, FLOAT, LONG, PIC ‘picture specification’

            Zero

String Fields:  CHAR, VARCHAR.

            Spaces.  Also, the length of Varchar variables is set to Zero

BIT fields

            B‘0’ (or X’0’ if appropriate)

DATE fields

            0/0/0000  

TIME fields

            00:00:00:000

DATETIME – combines DATE and TIME initialisation

GUID fields

            00000000-0000-0000-0000-000000000000

           

Groups are initialised by initialising all their elements, not by simply assigning Spaces or X’0’ to the whole group.