Version 4.2.6 for Mainframes
 —  Statements  —

Initial-Value Definition

The init-definition used in the variable-definition option of DEFINE DATA LOCAL, DEFINE DATA INDEPENDENT, DEFINE DATA CONTEXT and DEFINE DATA OBJECT has the following syntax:

<constant>

<system-variable>
FULL LENGTH <character-s>
LENGTH <character-s>

This document covers the following topics:

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.


Function

With the init-definition option, you define the initial/constant values for a variable.

Note:
If, in the variable-definition option, the keyword INIT was used for the initialization, the value may be modified by any statement that affects the content of a variable. If the keyword CONST was used for the initialization, any attempt to change the value will be rejected by the compiler.

See also Defining Fields, Initial Values in the Programming Guide.

Top of page

Restriction

For a redefined field, an init-definition is not permitted.

Top of page

Syntax Description

<constant> The constant value with which the variable is to be initialized; or the constant value to be assigned to the field. For further information on constants, see User-Defined Constants in the Programming Guide.
<system-variable> The initial value for a variable may also be the value of a Natural system variable. Example:
DEFINE DATA LOCAL
1 #MYDATE (D) INIT <*DATX> 
END-DEFINE

Note:
When the variable is referenced in a RESET INITIAL statement, the system variable is evaluated again; that is, it will be reset not to the value it contained when program execution started but to the value it contains when the RESET INITIAL statement is executed.

FULL LENGTH <character-s>

LENGTH n <character-s>

As initial value, a variable can be filled, entirely or partially, with a specific single character or string of characters; this is only possible for alphanumeric (code page or Unicode) variables.

With the FULL LENGTH option, the entire field will be filled with the specified character or characters. In the following example, the entire field will be filled with asterisks.

DEFINE DATA LOCAL
1 #FIELD (A25) INIT FULL LENGTH <'*'> 
END-DEFINE

With the LENGTH n option, the first n positions of the field will be filled with the specified character or characters. n must be a numeric constant. In the following example, the first 4 positions of the field will be filled with exclamation marks.

DEFINE DATA LOCAL
1 #FIELD (A25) INIT LENGTH 4 <'!'> 
END-DEFINE

Top of page