Record ExampleRecord 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
Record ExampleRecord type basicRecord myRecField INT = 2; end Program myProgram (myField03 INT = 3) myField04 STRING = "EGL"; function main() // myRecord.myRecField = 2 myRecord ExampleRecord; 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 to reflect the definition of record partB set B initial; // each of the next statements writes "1234" writeStdOut( A.aa ); writeStdOut( B.bb ); end end
Record ExampleRecord 10 charField CHAR(24); 15 hexField HEX(16); 15 remainder CHAR(16); endThe memory area for hexField is initialized with binary zeros, as is appropriate for HEX variables. The remainder field is initialized with blanks. It takes two HEX characters to make a single byte, so a HEX(16) variable takes up only 8 bytes.
In the case of an array, each member of the array is initialized individually.
Records or fields that are received as program or function arguments are never initialized automatically.
Nullable variables are a special case. Those created with the type extension character "?" are initialized to null. Those governed by the i4glItemsNullable property have a different set of initial values. See i4glItemsNullable.
Type | Initialization value |
---|---|
ANY | Null |
BIN (and the integer types), HEX, FLOAT, SMALLFLOAT | Binary zeros |
BLOB, CLOB | Reset using lobLib.freeBlob() or lobLib.freeClob() |
BOOLEAN | False |
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 |
STRING | "" (a null string) |
UNICODE | Unicode blanks (each of which is hexadecimal 0020) |
library lib1 a int = 1; b int = lib2.c; end library lib2 c int = 2; d int = lib1.a; end
If a program attempts to use either lib1 or lib2, EGL throws an exception.
Platform | Issue |
---|---|
COBOL generation | An EGL-generated COBOL program initializes all records. The fields within the records are initialized based upon the COBOL data type, after which the variables are initialized by EGL type as described in the table above, overriding the COBOL INITIALIZE statement. Note: If you generate a COBOL program that compares
a variable of type NUM with a variable of type CHAR, make sure that
your code initializes the fields; otherwise, the comparison can cause
the program to fail with an abend message. If this happens, no exception-handling
code is run. A similar, COBOL-specific warning applies to fields in
local records.
|
JavaScript generation | The following types are not supported: ArrayDictionary, BIN (with decimal places), BLOB, CHAR, CLOB, DBCHAR, HEX, INTERVAL, MBCHAR, NUMC, STRING (with a size limit), PACF, UNICODE, and structured Record parts. |