Record myRecordPart type basicRecord 10 myField CHAR(5); 20 myField01 CHAR(1) = "1"; 20 myField02 CHAR(1) = "2"; 20 myArray01 CHAR(1)[3] = ["a", "b", "c"]; // the following entry assigns "z" to the first element // and (in Java code) blanks to the rest 20 myArray02 CHAR(1)[3] = ["z"]; end
This rule also applies to form fields; however, you cannot specify an initializer in a DataTable.
Record myRecordPart type basicRecord myRecField INT = 2; end Program myProgram (myField03 INT = 3) myField04 STRING = "EGL"; function main() // myRecord.myRecField = 2 myRecord myRecordPart; end end
Record partA 10 aa char(4) = "abcd"; end Record partB 10 bb char(4) = "1234"; end Program Example A partA; B partB { redefines="A" }; function main() // each of the next statements writes "abcd" writeStdOut( A.aa ); writeStdOut( B.bb ); // sets the memory area in a way that reflects the definition of record partB set B initial; // each of the next statements writes "1234" writeStdOut( A.aa ); writeStdOut( B.bb ); end end
In a fixed structure, only the lowest-level structure fields are considered. If a structure field of type HEX is subordinate to a structure item of type CHAR, for example, the memory area is initialized with binary zeros, as is appropriate for HEX initialization.
Records or fields that are received as program or function parameters are never initialized automatically.
The next table gives details on the initialization values.
Primitive type | Initialization value |
---|---|
ANY | Variable is of an undefined type |
BIN (and the integer types), HEX, FLOAT, SMALLFLOAT | Binary zeros |
CHAR, MBCHAR | Single-byte blanks |
DATE, TIME, TIMESTAMP | Current value of the machine clock (for the number of bytes required by the mask, in the case of TIMESTAMP) |
DBCHAR | Double-byte blanks |
DECIMAL, MONEY, NUM, NUMC, PACF | Numeric zeros |
INTERVAL | Numeric zeros (for the number of bytes required by the mask), preceded by a plus sign |
UNICODE | Unicode blanks (each of which is hexadecimal 0020) |
Related concepts
Function part
DataItem part
Program part
Record parts
Fixed structure
Related reference
EGL statements
Primitive types
set