( |
index[:index] |
,
3
|
) |
< character-string, > |
||||||||||||||
< |
,
> |
|||||||||||||||||
ALL |
< character-string> |
||||||
< |
> |
For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.
The array-init-definition
option
is used to 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 Field Definitions in the Programming Guide, particularly the following sections:
This section covers the following topics:
For a redefined field, an
array-init-definition
is not
permitted.
Syntax Element | Description |
---|---|
ALL |
ALL Option:
All occurrences of the array are initialized with the same value. The |
index |
Index Option:
The array occurrences specified by
If a single index or an index range is used, you can only specify a
unique value ( Examples: DEFINE DATA LOCAL 1 #FLD1 (A4/1:4) INIT (1:3) <'A'> /* A fills occurrences (1:3) 1 #FLD2 (A4/1:4) INIT (*) <'B'> /* B fills all occurrences 1 #FLD3 (A4/1:2,1:4) INIT (2,3) <'C'> /* C fills occurrence (2,3) END-DEFINE |
V |
Index Notation V:
The special index notation You can specify the You can omit the Example showing which values fill which occurrences when
DEFINE DATA LOCAL 1 #FLD4 (A4/1:3) INIT (V) <'A','B'> /* A fills (1) B fills (2) 1 #FLD5 (A4/1:2,1:3) INIT (1,V) <'C','D'> /* C, D fill (1,1:2) (2,V) <'F','G','H'> /* F, G, H fill (2,1:3) END-DEFINE |
constant |
Constant Value Option:
The constant (value) with which the array is to be initialized. Occurrences for which no values are specified, are initialized with a default value. In a list of consecutive occurrences, you can skip single
occurrences by specifying commas ( For further information, see User-Defined Constants in the Programming Guide. Note: Example with DEFINE DATA LOCAL 1 #FLD1 (A4/1:3) INIT <'A',,'C'> 1 #NUM1 (N4,2/1:3) INIT <1 , 2 , 3> 1 #NUM2 (N4,2/1:3) INIT <1;2;3> END-DEFINE |
system-variable |
System Variable Option:
The initial value for an array can also be the value of a Natural system variable. See also the Note for
|
FULL LENGTH
<character-string>
|
Character String Option for Alphanumeric/Unicode
Variables:
For a variable of the Natural data format A or U, a
A FULL LENGTH Option:
With the LENGTH Option:
With the Example showing which values fill which occurrences: DEFINE DATA LOCAL 1 #FLD1 (A6/1:3) INIT ALL FULL LENGTH <'X'> /* XXXXXX in all occ. 1 #FLD2 (A6/1:3) INIT ALL LENGTH 5 <'NO'> /* NONON in all occ. 1 #FLD3 (A6/1:3) INIT (1:2) LENGTH 4 <'AB'> /* ABAB in occ (1:2) 1 #FLD4 (A6/1:3) INIT (V) FULL LENGTH <'X','Y'>/* XXXXXX in occ. (1), /* YYYYYY in occ. (2) END-DEFINE Within one
|
Note:
For further example definitions of assigning initial values to
arrays, see Example 2 - DEFINE DATA
(Array Definition/Initialization).