The array-init-definition option used in the
variable-definition option of
DEFINE DATA LOCAL
,
DEFINE DATA
INDEPENDENT
, DEFINE
DATA CONTEXT
and DEFINE DATA OBJECT
has the
following syntax:
ALL |
<character-s ...> | |||||||||||||
,...3 | ||||||||||||||
< |
system-variable,... |
> |
This document covers the following topics:
With an array-init-definition, you define the initial/constant values for an array.
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 in the Programming Guide, particularly the following sections:
For a redefined field, an array-init-definition is not permitted.
ALL | All occurrences in all dimensions of the array are initialized with the same value. |
---|---|
index | Only the array occurrences specified by the index are initialized. If you specify index, you can only specify one value with constant; that is, all specified occurrences are initialized with the same value. |
V | This notation is only relevant for multidimensional arrays if
the occurrences of one dimension are to be initialized with different values.
V indicates an index range that comprises all occurrences of the
dimension specified with V ; that is, all occurrences in that
dimension are initialized. Only one dimension per array may be specified with
V . The occurrences are initialized occurrence by occurrence with
the values specified for that dimension. The number of values must not exceed
the number of occurrences of the dimension specified with V .
|
constant | The constant (value) with which the array is to be initialized
(INIT ), or the constant to be assigned to the array
(CONSTANT ). For further information on constants, see
User-Defined
Constants in the Programming Guide.
Note: |
system-variable | The initial value for an array may also be the value of a
Natural system variable.
Note: |
As initial value, a variable can be filled, entirely or
partially, with a specific single character or string of characters (only
possible for variables of format A or U).
With With A system-variable must not be specified
with Within one array-init-definition, only
either |
In this example, the first 5 positions of each occurrence of the array
will be filled with NONON
.
DEFINE DATA LOCAL 1 #FIELD (A25/1:3) INIT ALL LENGTH 5 <'NO'> ... END-DEFINE
Numerous examples of assigning initial values to arrays are provided in the Programming Guide.