Navigation: Language Reference > 4 - Entity Declarations > File Structures >====== RECORD (declare record structure) ====== | |
[label] | RECORD [,PRE( )] [,NAME( )] |
fields | |
END |
RECORD | Declares the beginning of the data structure within the FILE declaration. |
fields | Multiple variable declarations. |
PRE | Specify a label prefix for the structure. |
NAME | Specifies an external name for the RECORD structure. |
The RECORD statement declares the beginning of the data structure within the FILE declaration. A RECORD structure is required in a FILE declaration. Each field is an element of the RECORD structure. The length of a RECORD structure is the sum of the length of its fields. When the label of a RECORD structure is used in an assignment statement, expression, or parameter list, it is treated as a GROUP data type.
At run time, static memory is allocated as a data buffer for the RECORD structure. The fields in the record buffer are available whether the file is open or closed.
If the fields contain variable declarations with initial values, that initial value is only used to determine the size of the variable, the record buffer is not initialized to the value. For example, a STRING('abc') field declaration creates a three-byte string, but it's value is not automatically initialized to 'abc' unless the program's executable code assigns it that value.
Records from the data file on disk are read into the data buffer with the NEXT, PREVIOUS, GET, or REGET statements. Data in the fields are processed, then written to the data file as a single RECORD unit by the ADD, APPEND, PUT, or DELETE statements.
The WHAT and WHERE procedures allow access to the fields by their relative position within the RECORD structure.
Example:
Names FILE,DRIVER('Clarion') !Declare a file structure Record RECORD ! begin record declaration Name STRING(20) ! declare name field Number SHORT ! declare number field END END !End file, end record declaration
See Also: