5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable Usage : Record Components
 
Share this page                  
Record Components
The syntax EQUEL uses to refer to a record component is the same as in Ada:
record.component{.component}
Syntax Notes:
1. The last record component denoted by the above reference must be a scalar value (integer, floating-point or character string). There can be any combination of arrays and records, but the last object referenced must be a scalar value. Thus, the following references are all legal:
    -- Assume correct declarations for "employee",
    --  "person" and other records.
    employee.sal   -- Component of a record
    person(3).name -- Component of an element of an
                               array
    rec1.mem1.mem2.age -- Deeply nested component
2. All record components must be fully qualified when referenced. You can shorten the qualification by using the Ada renames clause in another declaration to rename some components or nested records.
The following example uses the array of records "emprec" to load values into the tablefield "emptable" in form "empform."
##  type Employee_Rec is
##   record
##    ename: String(1..20);
##    eage: Short_Integer;
##    eidno: Integer;
##    ehired: String(1..25);
##    edept: String(1..10);
##    esalary: Float;
##  end record;
## emprec: array(1..100) of Employee_Rec;
...
for i in 1..100 loop
## loadtable empform emptable
##    (name = emprec(i).ename, age = emprec(i).eage,
##     idno = emprec(i).eidno, 
##     hired = emprec(i).ehired,
##     dept = emprec(i).edept, 
##     salary = emprec(i).esalary)
end loop;
If you want to shorten the reference to the record, you can use the renames clause to rename a particular member of the "emprec" array, as in the following example:
for i in 1..100 loop
##  declare
##    er: Employee_Rec renames emprec(i);
##  begin
##    loadtable empform emptable
##     (name = er.ename, age = er.eage,
##      idno = er.eidno, hired = er.ehired,
##      dept = er.edept, salary = er.esalary)
##  end;
end loop;