Try OpenEdge Now
skip to main content
Object-oriented Programming
Getting Started with Classes, Interfaces, and Objects : Using the INTERFACE construct
 

Using the INTERFACE construct

The INTERFACE construct represents all of the statements that can comprise an interface definition. The interface definition specifies a main block, starting with an INTERFACE statement that identifies the interface. After any USING statements, the first compilable line in a class definition file that defines an interface must be this INTERFACE statement. The last statement in an interface definition must be the END INTERFACE statement, which terminates the main block of the interface. An interface compiles to r-code similar to a class.
Note: The INTERFACE statement is only valid in a file with the .cls extension.
The main block of the interface contains statements that specify the property, method, and event names and signatures that any class implementing the interface must define. Interfaces do not specify data members to implement, but can contain temp-table and ProDataSet definitions that are used for parameters in specified property, method, or event prototypes. No allocation is associated with these definitions. These temp-table and ProDataSet definitions must occur before any property, method, or event prototypes in the main block of the interface are specified. Any class implementing an interface with temp-table or ProDataSet parameters must repeat those definitions within the class.
When compiling a class that implements an interface with temp-table or ProDataSet parameters, the definition of a given temp-table or ProDataSet in the implementing class must be compatible with the definition of the corresponding temp-table or ProDataSet in the interface. The compiler's compatibility rules are the same as those enforced when passing temp-table or ProDataSet parameters:
*Compatible temp-tables must have the same number of fields, with each field matching in data type, extent, and position, but not in field name or any other field attribute. The temp-tables must have the same number of indexes, with index components matching in every way (except in field name), and the index names must also match. The temp-table names do not have to match.
*Compatible ProDataSets must have the same number of member buffers, in the same order, and the tables of those buffers must match in the same way as compatible temp-tables. Names of either the ProDataSet or its buffers do not have to match.
* INTERFACE statement
* Using an interface definition