User manual

mikroPascal PRO for PIC32
MikroElektronika
191
Units
In mikroPascal PRO for PIC32, each project consists of a single project le and one or more unit les. Project le, with
extension .mpp32 contains information about the project, while unit les, with extension .mpas, contain the actual
source code.
Units allow you to:
- break large programs into encapsulated parts that can be edited separately,
- create libraries that can be used in different projects,
- distribute libraries to other developers without disclosing the source code.
Each unit is stored in its own le and compiled separately. Compiled units are linked to create an application. In order
to build a project, the compiler needs either a source le or a compiled unit le (.emcl le) for each unit.
Uses Clause
mikroPascal PRO for PIC32 includes units by means of the uses clause. It consists of the reserved word uses, followed
by one or more comma-delimited unit names, followed by a semicolon. Extension of the le should not be included.
There can be at most one uses clause in each source le, and it must appear immediately after the program (or unit)
name.
Here’s an example:
uses utils, strings, Unit2, MyUnit;
For the given unit name, the compiler will check for the presence of .emcl and .mpas les, in order specied by the
search paths.
- If both .mpas and .emcl les are found, the compiler will check their dates and include the newer one in the
project. If the .mpas le is newer than .emcl, a new library will be written over the old one;
- If only .mpas le is found, the compiler will create the .emcl le and include it in the project;
- If only .emcl le is present, i.e. no source code is available, the compiler will include it as it is found;
- If none found, the compiler will issue a “File not found” warning.
Main Unit
Every project in mikroPascal PRO for PIC32 requires a single main unit le. The main unit le is identied by the
keyword program at the beginning; it instructs the compiler where to “start”.
After you have successfully created an empty project with the Project Wizard, the Code Editor will display a new main
unit. It contains the bare-bones of the Pascal program:
program MyProject;
{ main procedure }
begin
{ Place program code here }
end.