- 2.2.10.2 -
TMT Pascal Language Description
Pascal Language Structure
Programs and UnitsPrograms
Programs require a different format from units. The general format
takes the following form:
[program identifier;]
[uses
Unitname [, Unitname]]
[Declaration]
begin
statement [; statement]
end.
The identifier following the program statement declares the name
of the program. Program files are terminated by the end statement
followed by a period (.).
The uses statement tells TMT Pascal which units it uses.
Unitnames listed after the uses statement are loaded by TMT
Pascal. Procedures and variables referenced by the program are linked into
the executable generated. All types, constants, variables, and functions
declared in the Interface section of units are accessible to the program.
All text beyond the final end statement in either a unit or program
is ignored by TMT Pascal.
In TMT Pascal the main program
may contain interface and implementation parts as well.
This allows access to the variables of the main program from other modules:
// Test Program
program Test;
interface
var
global: Integer;
implementation
uses
UnitTest;
begin
UnitTest.Write;
end.
// Test Unit
unit UnitTest;
interface
procedure Write_global;
implementation
uses
Test;
procedure Write_global;
begin
Write(test.global);
end;
end.
The name of the file that contains
the text of the main program or unit must be identical with the name that
follows the keyword program.
|
|
|
Units |
Table of Content |
Dynamic-Link Libraries (DLL's) |
- 2.2.10.2 -