7. Embedded QUEL for Pascal : Pascal Variables and Data Types : Variable Usage : Record Components
 
Share this page                  
Record Components
The syntax EQUEL uses to refer to a record component is:
record_name{^ | [subscript]}.component{^ | [subscript]}{.component{^ |     [subscript]}}
that is, the name of the record, followed by any number of pointer dereference operators or array subscripts, followed by one or more field names (with any number of pointer dereference operators or array subscripts attached).
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 Pascal with statement (see below).
3. Any array subscripts or pointer references referred to in the record reference, and not at the very end of the reference, are not checked by the preprocessor. Consequently, both of the following references are accepted, even though one must be wrong, depending on whether "person" is an array:
person[1].age
person.age
The following example uses the array of records "emprec" to load values into the table field "emptable" in form "empform."
##  type
##      EmployeeRec = record
##          ename: packed array[1..20] of Char;
##          eage: [word] -32768 .. 32767;
##          eidno: Integer;
##          ehired: packed array[1..25] of Char;
##          edept: packed array[1..10] of Char;
##          esalary: Real;
##    end;
##  var
##      emprec: array[1..100] of EmployeeRec;
##      i: Integer;

    ...

    for i := 1 to 100 do
    begin
##    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;