The With Statement
You can use the with statement to shorten a reference to a record. The syntax of the with statement is:
with record_reference do
begin
statements
end [;]
where record_reference is
record_name{^ | [subscript]}{.component{^ | [subscript]}}
that is, the name of a record, followed by any number of pointer dereference operators or array subscripts, followed by zero or more field names (with any number of pointer dereference operators or array subscripts attached).
Following the rules of Pascal,
## with rec_a, rec_b do
## begin
## ...
## end;
is exactly equivalent to
## with rec_a do
## begin
## with rec_b do
## begin
## ...
## end;
## end;
Syntax Notes:
1. The with statement, along with its begin and end clauses, must be preceded by the EQUEL ## mark in order to be used with EQUEL statements.
2. The record_reference must denote a record variable, not a scalar variable.Note that the with statement opens the scope of the record so that the member names can stand alone. This creates the possibility that a member name could conflict with the name of an Ingres object. For example, assume that there is an Ingres form called "rname":
## var
## rec : record
## rname : packed array[1..12] of char;
## ri : integer;
## end;
...
## with rec do
## begin
## forminit rname
## sleep ri;
## end;
In the forminit statement, "rname" refers to "rec.rname," not to the form called "rname," even though outside the scope of the with statement it would unambiguously refer to the form. To refer to the form, you must either dereference the name:
## forminit #rname
or enclose it in quotes:
## forminit 'rname'
The following example uses the array of records "emprec," declared in previous example , to load values into the emptable table field in form "empform."
for i := 1 to 100 do
begin
## with emprec[i] do
## begin
## loadtable empform emptable
## (name = ename, age = eage,
## idno = eidno, hired = ehired,
## dept = edept, salary = esalary)
## end;
end;