6. Embedded QUEL for BASIC : BASIC Variables and Data Types : Variable and Type Declarations : Record Type Definitions
 
Share this page                  
Record Type Definitions
EQUEL accepts BASIC record definitions. The syntax of a record definition is:
record identifier
               record_component
              {record_component}
end record [identifier]
where record_component can be any of the following:
type identifier [(dimensions)] [str_length
              {[typeidentifier [(dimensions)] [str_length]}
group_clause
variant_clause
host_code
In turn, the syntax of a group_clause is:
group identifier [(dimensions)]
               record_component
              {record_component}
              end group [identifier]
The syntax of a variant_clause is:
variant
              
 case_clause
              {case_clause}
end variant
where case_clause consists of:
case
              
record_component
Syntax Notes:
1. The type must be a BASIC type acceptable to EQUEL or a record type already defined to EQUEL. Note that the type is mandatory for EQUEL declarations because EQUEL has no notion of a default type. The type need only be specified once when declaring a list of variables of the same type.
2. The string length clause is allowed only for record components of type string.
3. The host code record component allows you to declare components of records without informing EQUEL of their existence. For instance, you may want to declare fill items or components whose type is not allowed in an EQUEL declaration. For example, the following record definition is acceptable to EQUEL:
##   record dept_rec
##        double net_profit
          gfloat gross_sales  ! Not for use with EQUEL statements
##   end record
4. Record definitions must appear before declarations using that record type. An exception occurs where a parameter to an EQUEL subroutine or function is of the record type. In that case, you may define the record to EQUEL after declaring it in the parameter list.
The following example illustrates the use of record type definitions:
##  record emp_history
##             string ename = 30
##             group prev_employers(10)
##                  string comp_name = 30
##                  real salary
##                  integer num_years
##  end group prev_employers
##  end record emp_history

##  record emp_sports
##               string ename = 30
##               variant
##                    case
##                         group golf
##                              integer handicap
##                              string club_name
##                         end group golf
##                    case
##                         group baseball
##                              integer batting_avg
##                              string team_name
##                         end group baseball
##                    case
##                         group tennis
##                              integer seed
##                              string club_name
##                         end group tennis
##               end variant
##  end record emp_hobbies