User manual

194
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Modules
In mikroBasic PRO for dsPIC30/33 and PIC24, each project consists of a single project le and one or more module
les. The project le, with extension .mbpds contains information on the project, while modules, with extension .mbas,
contain the actual source code. See Program Organization for a detailed look at module arrangement.
Modules allow you to:
- break large programs into encapsulated modules 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 module is stored in its own le and compiled separately; compiled modules are linked to create an application. To
build a project, the compiler needs either a source le or a compiled module le for each module.
Include Clause
mikroBasic PRO for dsPIC30/33 and PIC24 includes modules by means of the include clause. It consists of the
reserved word include, followed by a quoted module name. Extension of the le should not be included.
You can include one le per include clause. There can be any number of the include clauses in each source le,
but they all must be stated immediately after the program (or module) name.
Here’s an example:
program MyProgram
include “utils”
include “strings”
include “MyUnit”
...
For the given module name, the compiler will check for the presence of .mcl and .mbas les, in order specied by
search paths.
- If both .mbas and .mcl les are found, the compiler will check their dates and include the newer one in
the project. If the .mbas le is newer than the .mcl, then .mbas le will be recompiled and new .mcl will
be created, overwriting the old .mcl.
- If only the .mbas le is found, the compiler will create the .mcl le and include it in the project;
- If only the .mcl le is present, i.e. no source code is available, the compiler will include it as found;
- If none of the les found, the compiler will issue a “File not found” warning.
Main Module
Every project in mikroBasic PRO for dsPIC30/33 and PIC24 requires a single main module le. The main module 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 Project Wizard, Code Editor will display a new main module.
It contains the bare-bones of the program: