4. Embedded QUEL for Fortran : Fortran Variables and Data Types : Variable and Type Declarations : Structure and Record Declarations
 
Share this page                  
Structure and Record Declarations
EQUEL/Fortran supports the declaration and use of user-defined structure variables. The syntax of a structure definition is:
structure [/structdef_name/] [field_namelist]
                             field_declaration
                            {field_declaration}
end structure
Syntax Notes:
The structdef_name is optional only for a nested structure definition.
The field_namelist is allowed only with a nested structure definition. Each name in the field_namelist constitutes a field in the enclosing structure.
The field_declaration can be a typed data declaration (see Typed Data Declarations), a nested structure declaration, a union declaration, a record declaration, or a fill item.
The syntax of a union declaration is as follows:
union
                     
 map_declaration
                      map_declaration
       {map_declaration}
       end union
where map_declaration is:
       map
              
 field_declaration
              {field_declaration}
       end map
Only field_declarations that are referenced in EQUEL statements need to be declared to EQUEL. The following example declares a Fortran structure with a member "checked" that is not known to EQUEL.
## structure /address/
## integer number
## character*20 street 
## character*10 town
## integer*2 zip
 logical checked 
## end structure
## record /address/addr
To use a structure with EQUEL statements, you must both define the structure and declare the structure's record to EQUEL. The record declaration has the following syntax:
record /structdef_namestructurename {,[/structdef_name/]
                                           structurename}
Syntax Note:
The structdef_name must be previously defined in a structure statement.
For information on the use of structure variables in EQUEL statements, see Using a Structure Member.
The following example includes a structure definition and a record declaration:
## structure /name_map/
## union
## map
##  character*30 fullname
## end map
## map
##  character*10 firstnm
##  character*2 init
##  character*18 lastnm
## end map
## end union
## end structure

## record /name_map/ empname
The next example shows the definition of a structure containing an array of nested structures:
## structure /class_struct/
## character*10 subject
## integer*2 year
## structure student(100)
C No structure definition name needed
## character*12 name
## byte grade
## end structure
## end structure

## record /class_struct/ classrec