Structures let you call an external routine that expects a structure argument containing a field whose value is a pointer to another structure. You can use the copy action statement with the handle of built-in function to copy the handle of the quoted name of one structure into an integer field in another structure or to an ESL integer variable. For example:
structure Employee is
string Name
integer AddressPtr
end structure
structure Address is
string Street
City
State
Zip
end structure
# Structure variable declarations:
structure Employee Emp structure Address Addr
# External subroutine declaration:
subroutine PRINT_ADDRLABEL ( structure Employee: EmpRec )
library "Prt_Rtns"
copy ScreenStreet to Addr.Street
copy ScreenCity to Addr.City
copy ScreenState to Addr.State
copy ScreenZip to Addr.Zip
copy ScreenName to Emp.Name
# Copy handle of one structure into field in another
copy handle of "Addr" to Emp.AddressPtr
# Call routine to print address label
call PRINT_ADDRLABEL (Emp)
This example defines two structure types, Employee and Address. Employee contains an integer field, AddressPtr, designed to hold a pointer. The example declares two structure variables, Emp and Addr, and a subroutine, PRINT_ADDRLABEL. It populates the two structure variables with data, and copies the handle of the quoted name of the Addr structure variable into the Emp structure variable. Finally, it calls the subroutine PRINT_ADDRLABEL, passing the Emp structure variable as an argument.