5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable Usage : Access Variables
 
Share this page                  
Access Variables
An access variable must qualify another object by means of the dot operator, using the same syntax as a record component:
access.reference
Syntax Notes:
1. By the time an access variable is referenced, the type to which it is pointing must be fully defined. This is true even for access types that were declared to point at incomplete types.
2. The final object denoted by the above reference must be a scalar value (integer, floating-point or character string). There can be any combination of arrays, records or access variables, but the last object referenced must be a scalar valuIf an access variable is pointing at a scalar-valued type, then the qualification must include the Ada .all clause to refer to the scalar value. If used, the .all clause must be the last component in the qualification. For example:
## type Access_Integer is access Integer;
## ai: Access_Integer;
  ...
ai := new Integer'(2);
## sleep ai.all
In the following example, an access type to an employee record is used to load a linked list of values into the Employee database table:
## type Employee_Rec;
## type Emp_Link is access Employee_Rec;
## type Employee_Rec is
##   record
##     ename: String(1..20);
##     eage: Short_Integer;
##     eidno: Integer;
##     enext: Emp_Link;
##   end record;
## elist: Emp_Link;
...
while (elist /= null) loop
##  repeat append to employee
##    (name = @elist.ename, age = @elist.eage,
##     idno = @elist.eidno)
elist := elist.enext;
end loop;