set considerations for file I/O
In the context of file I/O that does not involve databases, the EGL set statement can reset all the fields in a record variable and, in the case of the IndexRecord stereotype, can change the position of the file pointer.
When you use this statement with the CSVRecord stereotype, the only permitted form is set empty.
Syntax

- recordVariable
- The name of an indexed, relative, or serial record variable that the set statement acts upon.
- value
- This is the type
of set operation to
be carried out. The following values are possible:
- empty
- Here the set statement works recursively through all record variables that are contained within the record, or, in the case of a structured record, works down to the lowest level of the structure. Individual fields are set according to their types. For details of those values, see Data initialization.
- initial
- A record variable can specify an initial value for each of its fields. The initial modifier resets the values of those fields to the values that are specified in the record definition. If the record definition does not specify any initial values, the effect of the initial modifier is the same as that of the empty modifier.
- position
- This keyword is available only for the IndexedRecord stereotype.
Example
The following example
shows the set statement
used with an indexed record:
package com.companyb.customer;
Record IndexedRecordExample type IndexedRecord {
fileName = "C:\\temp\\indexfile.txt",
keyItem = indKey
}
10 indKey INT;
15 indKeyAsHex HEX(8);
10 indTitle CHAR(30);
10 indAuthor CHAR(30);
end
program readall
myIndexedRecord IndexedRecordExample;
Function main()
// sets indKey to 0, other fields blank
set myIndexedRecord empty;
myIndexedRecord.indKeyAsHex = x"FFFFFFFF";
// moves to end of file
set myIndexedRecord position;
...
end // main()
end // program