Previous: 2.2.10.1. Units To the Table of Contents Next: 2.2.11. Dynamic-Link Libraries (DLL's)
2.2.10.1. Units Table of Contents 2.2.11. Dynamic-Link Libraries (DLL's)

- 2.2.10.2. -
Table of Contents
2. TMT Pascal Language Description
2.2. Pascal Language Structure
2.2.10. Programs and Units
2.2.10.2. Programs


2.2.10.2. Programs


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.


Previous: 2.2.10.1. Units To the Table of Contents Next: 2.2.11. Dynamic-Link Libraries (DLL's)
2.2.10.1. Units Table of Contents 2.2.11. Dynamic-Link Libraries (DLL's)

- 2.2.10.2. -