Language:
Русский
English
unit (reserved word)
Units are the basis of modular programming in Borland Pascal. You use units to create libraries and to divide large programs into logically related modules.
Syntax
unit identifier; { Heading }
interface { Public symbols }
uses { Uses clause }
const { Constants }
type { Types }
var { Variables }
procedure { Procedures }
function { Functions }
implementation { Private symbols }
uses { Uses clause }
label { Labels }
const { Constants }
type { Types }
var { Variables }
procedure { Procedures}
function { Functions }
begin { Initialization }
statement; { Statements }
statement
end.
These are the parts of a unit,:
- unit heading
- interface part
- implementation part
- initialization part
Unit heading
The unit heading specifies the unit's name, which you use when referring to the unit in a uses clause.
Interface part
The interface part declares constants, types, variables, procedures, and functions that are public (available to the users of the unit).
Procedures and functions are listed only as headings in the interface part. The bodies of the procedures and functions are in the implementation part.
Implementation part
The implementation part defines the bodies of all public procedures and functions.
In addition, it declares constants, types, variables, procedures, and functions that are private and not available to the users of the unit.
Initialization part
The initialization part is the last part of a unit. It consists of either:
- the reserved word end (no initialization code),or
- a statement part to be executed in order to initialize the unit